/* ============================================
   CSS VARIABLES - 3 COLOR SCHEMES
   ============================================ */
:root {
    /* Common */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    /* NEO UI Kit - Стандартизированные размеры */
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 16px;
    
    /* Отступы */
    --padding-sm: 10px 12px;
    --padding-md: 16px 20px;
    --padding-lg: 20px 24px;
    
    /* Шрифты (+20% к размеру) */
    --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-sm: 15px;    /* было 13px */
    --font-size-md: 17px;    /* было 14px */
    --font-size-lg: 19px;    /* было 16px */
    
    /* Сетка */
    --grid-gap: 16px;
    --card-min-width: 300px;
}

/* ROBOTO 400 - Применяем к элементам, но не иконкам */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    font-size: var(--font-size-lg);  /* 19px для всего текста */
    line-height: 1.5;
    overflow-y: auto;
    /* Кроссбраузерное сглаживание шрифтов */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "liga" 1, "kern" 1;
}

/* Табличные цифры для финансов и статистики */
#billing-balance, #billing-spent, #billing-plan, .stat-value, .transaction-amount {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Мелкий текст — разреженнее для читаемости */
.badge, .tag, .sidebar-label, .nav-item span {
    letter-spacing: 0.02em;
}

/* Все текстовые элементы */
div, span, p, a:not([class*="fa-"]):not([class*="pe-7s-"]), 
li, td, th, label {
    font-family: var(--font-sans);
    font-weight: 400;
}

/* Поля ввода и кнопки */
input, select, textarea, button:not([class*="fa-"]) {
    font-family: var(--font-sans);
    font-weight: 400;
}

/* Заголовки без bold + фиксированные размеры (не +20%) */
h1 { font-size: 28px; font-weight: 400; }
h2 { font-size: 24px; font-weight: 400; }
h3 { font-size: 20px; font-weight: 400; }
h4 { font-size: 18px; font-weight: 400; }
h5, h6 { font-size: 16px; font-weight: 400; }

b, strong {
    font-weight: 400;
}

/* NEON THEME (Default) */
[data-theme="neon"] {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-card: rgba(22, 22, 42, 0.6);
    --bg-dropdown: rgba(22, 22, 42, 0.85);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b7b;
    --accent: #00f5ff;
    --accent-secondary: #ff00ff;
    --accent-tertiary: #7b2dff;
    --success: #00ff88;
    --warning: #ffdd00;
    --danger: #ff3366;
    --info: #00ccff;
    --border: rgba(0, 245, 255, 0.2);
    --gradient-primary: linear-gradient(135deg, #00f5ff 0%, #7b2dff 100%);
    --gradient-glow: radial-gradient(circle at 50% 50%, rgba(0, 245, 255, 0.15) 0%, transparent 70%);
    --glass: rgba(22, 22, 42, 0.7);
    --shadow: 0 4px 16px rgba(0, 245, 255, 0.1);
    --shadow-hover: 0 6px 24px rgba(0, 245, 255, 0.18);
}

/* WARM/LIGHT THEME */
[data-theme="warm"] {
    --bg-primary: #faf6f0;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f0e8;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-dropdown: rgba(255, 255, 255, 0.85);
    --text-primary: #2d2418;
    --text-secondary: #5c4d3c;
    --text-muted: #8b7d6b;
    --accent: #ff9500;
    --accent-secondary: #ff6b00;
    --accent-tertiary: #e68200;
    --success: #7cb342;
    --warning: #ffa726;
    --danger: #ef5350;
    --info: #42a5f5;
    --border: rgba(255, 149, 0, 0.25);
    --gradient-primary: linear-gradient(135deg, #ff9500 0%, #ffb700 100%);
    --gradient-glow: radial-gradient(circle at 50% 50%, rgba(255, 149, 0, 0.1) 0%, transparent 70%);
    --glass: rgba(255, 255, 255, 0.75);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.1);
}

/* FRESH THEME (Green) */
[data-theme="fresh"] {
    --bg-primary: #f0f7f0;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8f5e9;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-dropdown: rgba(255, 255, 255, 0.85);
    --text-primary: #1b3d1b;
    --text-secondary: #4a6b4a;
    --text-muted: #7a9a7a;
    --accent: #4caf50;
    --accent-secondary: #2e7d32;
    --accent-tertiary: #66bb6a;
    --success: #43a047;
    --warning: #ffa726;
    --danger: #ef5350;
    --info: #29b6f6;
    --border: rgba(76, 175, 80, 0.25);
    --gradient-primary: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
    --gradient-glow: radial-gradient(circle at 50% 50%, rgba(76, 175, 80, 0.1) 0%, transparent 70%);
    --glass: rgba(255, 255, 255, 0.75);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.1);
}

/* COOL THEME (Blue) */
[data-theme="cool"] {
    --bg-primary: #f0f5fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e3f2fd;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-dropdown: rgba(255, 255, 255, 0.85);
    --text-primary: #1a237e;
    --text-secondary: #3949ab;
    --text-muted: #5c6bc0;
    --accent: #2196f3;
    --accent-secondary: #1976d2;
    --accent-tertiary: #64b5f6;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --info: #00bcd4;
    --border: rgba(33, 150, 243, 0.25);
    --gradient-primary: linear-gradient(135deg, #2196f3 0%, #64b5f6 100%);
    --gradient-glow: radial-gradient(circle at 50% 50%, rgba(33, 150, 243, 0.1) 0%, transparent 70%);
    --glass: rgba(255, 255, 255, 0.75);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.1);
}

/* ============================================
   BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    transition: var(--transition);
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-glow);
    pointer-events: none;
    z-index: -1;
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--gradient-glow);
}

.login-card {
    background: var(--glass);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--border);
    padding: 48px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-hover), 0 0 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card h1 {
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 8px;
    text-align: center;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    text-align: center;
    font-size: 0.95rem;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    margin: 8px 0;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 245, 255, 0.1);
}

/* ============================================
   BUTTONS
   ============================================ */
button {
    padding: 10px 18px;
    background: var(--gradient-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 20px var(--accent);
}

button:active {
    transform: translateY(0);
}

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

button.secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

button.accent,
.button.accent {
    background: var(--accent) !important;
    color: #0a0a0f !important;
    font-weight: 500 !important;
}

button.success,
.button.success {
    background: var(--success) !important;
    color: #0a0a0f !important;
    font-weight: 500 !important;
}

button.danger,
.button.danger {
    background: var(--danger) !important;
    color: #fff !important;
}

button.warning,
.button.warning {
    background: var(--warning) !important;
    color: #0a0a0f !important;
    font-weight: 500 !important;
}

button.info,
.button.info {
    background: var(--info) !important;
    color: #0a0a0f !important;
    font-weight: 500 !important;
}

button.icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ============================================
   LAYOUT - APP
   ============================================ */
.app {
    display: none;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR - Glassmorphism
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 220px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    z-index: 100;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    height: 60px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    flex-shrink: 0;
}

.sidebar-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 400;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.sidebar-header h2 i {
    font-size: 1.75rem;
    background: none;
    -webkit-text-fill-color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    padding: 4px 0;
    overflow-y: auto;
}

/* Compact Sidebar Mode */
.sidebar.compact {
    width: 60px;
}

.sidebar.compact .sidebar-header h2 span {
    display: none;
}

.sidebar.compact .nav-item span {
    display: none;
}

.sidebar.compact .nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.compact .sidebar-label {
    display: none;
}

.sidebar.compact .sidebar-section {
    margin-top: 0;
}

.sidebar.compact ~ .top-bar,
.sidebar.compact ~ .main-content {
    margin-left: 60px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    margin: 0;
    border-radius: 0;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 400;
    position: relative;
    overflow: hidden;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    width: 100%;
    text-align: left;
    font-size: 13px;
}

.nav-item:last-of-type {
    border-bottom: none;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
    transform: scaleY(0);
    transition: var(--transition);
}

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

.nav-item.active {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.nav-item.active::before {
    transform: scaleY(1);
}

/* Search Tabs */
.search-tab {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 20px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-tab:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
}

.search-tab.active {
    border: 1px solid var(--accent);
    background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    color: var(--accent);
}

/* ============================================
   ADAPTIVE SEARCH TOOLBAR - NEO UI Kit
   ============================================ */
.tavily-tabs-container {
    position: sticky;
    top: 0;
    z-index: 101;
    background: var(--bg-card);
    padding: 0;
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--border);
}

.tavily-tabs-container.sticky {
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* Adaptive toolbar layout */
.search-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    min-height: 52px;
}

/* Left group - main actions */
.search-toolbar-left {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
}

/* Right group - secondary actions */
.search-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 0 0 auto;
    margin-left: auto;
    align-items: center;
}

/* Tab buttons - base styles */
.search-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex: 0 0 auto;
}

.search-tab:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--text-primary);
}

.search-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.search-tab i {
    font-size: 1rem;
    flex-shrink: 0;
}

.search-tab .badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    color: inherit;
    flex-shrink: 0;
}

.search-tab.active .badge {
    background: rgba(255,255,255,0.3);
}

/* Compact mode when sticky */
.tavily-tabs-container.sticky .search-toolbar {
    padding: 8px 12px;
}

.tavily-tabs-container.sticky .search-tab {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.tavily-tabs-container.sticky .search-tab i {
    font-size: 0.9rem;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Large screens - full layout */
@media (min-width: 1200px) {
    .search-tab {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    
    .search-tab i {
        font-size: 1.1rem;
    }
}

/* Tablets and small desktops */
@media (max-width: 991px) {
    .search-toolbar {
        gap: 5px;
        padding: 10px;
    }
    
    .search-tab {
        padding: 7px 12px;
        font-size: 0.8rem;
    }
    
    .search-tab i {
        font-size: 0.95rem;
    }
}

/* Mobile landscape and small tablets */
@media (max-width: 767px) {
    .search-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }
    
    .search-toolbar-left,
    .search-toolbar-right {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }
    
    .search-tab {
        flex: 1 1 calc(33.333% - 4px);
        min-width: 100px;
        justify-content: center;
        padding: 10px 8px;
    }
}

/* Mobile portrait */
@media (max-width: 479px) {
    .search-toolbar {
        padding: 8px;
        gap: 6px;
    }
    
    .search-toolbar-left,
    .search-toolbar-right {
        gap: 6px;
    }
    
    .search-tab {
        flex: 1 1 calc(50% - 3px);
        min-width: 80px;
        padding: 10px 6px;
        font-size: 0.75rem;
        gap: 4px;
    }
    
    .search-tab i {
        font-size: 1rem;
    }
    
    .search-tab .badge {
        font-size: 0.65rem;
        padding: 1px 5px;
    }
}

/* Extra small screens */
@media (max-width: 359px) {
    .search-tab {
        flex: 1 1 100%;
        padding: 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .search-tab {
        min-height: 40px;
    }
    
    .search-tab:active {
        transform: scale(0.98);
    }
}

/* Sticky Article Card Header */
.tavily-article-card {
    position: relative;
}

.tavily-article-header {
    position: sticky;
    top: 70px;
    z-index: 50;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(245, 245, 250, 0.98);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 10px 16px;
}

[data-theme="neon"] .tavily-article-header,
.tavily-article-header {
    background: rgba(30, 30, 40, 0.98);
}

[data-theme="warm"] .tavily-article-header {
    background: rgba(255, 250, 245, 0.98);
}

[data-theme="fresh"] .tavily-article-header {
    background: rgba(245, 255, 250, 0.98);
}

[data-theme="cool"] .tavily-article-header {
    background: rgba(245, 250, 255, 0.98);
}

.tavily-article-header .article-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
    flex-shrink: 0;
}

.tavily-article-header .article-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.tavily-article-header .article-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.tavily-article-header .article-actions button {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    white-space: nowrap;
}

.tavily-article-header .article-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tavily-article-header .article-actions button i {
    font-size: 0.8rem;
}

/* Diagram Styles */
.diagram-container {
    font-family: inherit;
}

.diagram-node {
    transition: all 0.3s ease;
}

.diagram-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.diagram-node-input:hover {
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
}

.diagram-node-output:hover {
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.4);
}

.diagram-node-stage:hover {
    background: var(--bg-card);
}

.diagram-item {
    transition: all 0.2s ease;
}

.diagram-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.diagram-level {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

.diagram-level:nth-child(1) { animation-delay: 0.1s; }
.diagram-level:nth-child(3) { animation-delay: 0.2s; }
.diagram-level:nth-child(5) { animation-delay: 0.3s; }
.diagram-level:nth-child(7) { animation-delay: 0.4s; }
.diagram-level:nth-child(9) { animation-delay: 0.5s; }
.diagram-level:nth-child(11) { animation-delay: 0.6s; }
.diagram-level:nth-child(13) { animation-delay: 0.7s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mind Map Styles */
.mindmap-container {
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.mindmap-node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.mindmap-node:hover circle {
    filter: brightness(1.2);
    transform: scale(1.1);
}

.mindmap-node:hover text {
    font-weight: bold;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.nav-item i {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Stroke 7 icons in menu */
.nav-item [class^="pe-7s-"] {
    font-size: 1.5rem;
    font-weight: normal;
}

/* Sidebar header icon */
.sidebar-header h2 i {
    font-size: 1.75rem;
}

/* Theme buttons icons */
.theme-btn i {
    font-size: 1.2rem;
}

/* Stroke 7 icons base styles */
[class^="pe-7s-"], [class*=" pe-7s-"] {
    font-family: 'Pe-icon-7-stroke';
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Theme switcher in sidebar */
.theme-switcher {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: center;
}

.theme-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--accent);
}

.theme-btn.neon {
    background: linear-gradient(135deg, #00f5ff, #ff00ff);
}

.theme-btn.warm {
    background: linear-gradient(135deg, #ff8c42, #d4a574);
}

.theme-btn.fresh {
    background: linear-gradient(135deg, #38b2ac, #2c7a7b);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
/* TOP Bar - Верхняя панель в стиле современных интерфейсов */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    margin-left: 220px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    height: 60px;
    box-sizing: border-box;
}

.top-bar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    max-width: 100%;
    height: 100%;
}

/* Левая и правая секции */
.top-bar-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Кнопки-иконки */
.top-bar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.top-bar-icon:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--accent);
}

.top-bar-icon i {
    font-size: 1rem;
}

/* Индикатор уведомлений */
.top-bar-indicator {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

/* Поиск в центре */
.top-bar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.top-bar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.top-bar-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.top-bar-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-card);
}

.top-bar-search input::placeholder {
    color: var(--text-muted);
}

/* Аватар */
.top-bar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.top-bar-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px var(--accent);
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a0a0f;
    font-size: 0.875rem;
    font-weight: 500;
}

.avatar-placeholder img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Выпадающие меню */
.top-bar-dropdown {
    position: relative;
}

.top-bar-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 6px;
    z-index: 100;
}

.top-bar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.top-bar-dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.top-bar-dropdown-item i {
    font-size: 0.875rem;
    color: var(--accent);
}

.top-bar-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* Avatar Styles */
.avatar-preview-large {
    width: 120px;
    height: 120px;
    min-width: 120px;
    min-height: 120px;
    max-width: 120px;
    max-height: 120px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 3px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
    box-sizing: border-box;
}

.avatar-preview-large:hover {
    border-color: var(--accent);
}

.avatar-placeholder-large {
    font-size: 3rem;
    color: var(--accent);
    font-weight: 500;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#avatar-image {
    width: 120px !important;
    height: 120px !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
    max-width: 120px !important;
    max-height: 120px !important;
    box-sizing: border-box !important;
}

#avatar-image.avatar-image-hidden {
    display: none;
}

/* Help Drawer */
.help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20%;
    min-width: 280px;
    max-width: 400px;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    z-index: 200;
    transform: translateX(100%);
    font-size: 1rem;
    line-height: 1.6;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.help-drawer.active {
    transform: translateX(0);
}

.help-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 60px;
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
    flex-shrink: 0;
}

.help-drawer-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.help-drawer-close:hover {
    color: var(--accent);
}

.help-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.help-section {
    margin-bottom: 28px;
}

.help-section h4 {
    margin: 0 0 16px 0;
    color: var(--accent);
    font-size: 1rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}

.help-section ul {
    margin: 0;
    padding-left: 24px;
}

.help-section li {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.help-section a {
    color: var(--accent);
    text-decoration: none;
}

.help-section a:hover {
    text-decoration: underline;
}

.help-section p {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Avatar Crop Modal */
.avatar-crop-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.avatar-crop-modal.active {
    display: flex;
}

.avatar-crop-container {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 24px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.avatar-crop-area {
    position: relative;
    width: 100%;
    height: 300px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 20px;
}

.avatar-crop-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.avatar-crop-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 2px dashed var(--accent);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.avatar-crop-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.main-content {
    margin-left: 220px;
    padding: 20px 24px;
    min-height: calc(100vh - 80px);
    transition: var(--transition);
}

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

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header h1 i {
    color: var(--accent);
    font-size: 26px;
}

/* ============================================
   CARDS - Glassmorphism
   ============================================ */
.card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
    transform: translateY(-4px);
}

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

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h2 i {
    color: var(--accent);
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: var(--transition);
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card h3 i {
    color: var(--accent);
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================
   LIST ITEMS
   ============================================ */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

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

.list-item:hover {
    background: var(--bg-tertiary);
}

.item-info h4 {
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.item-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.item-info p i {
    margin-right: 6px;
    color: var(--accent);
    font-size: 0.75rem;
}

.item-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: rgba(0, 255, 136, 0.15);
    color: var(--success);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.badge-warning {
    background: rgba(255, 221, 0, 0.15);
    color: var(--warning);
    border: 1px solid rgba(255, 221, 0, 0.3);
}

.badge-danger {
    background: rgba(255, 51, 102, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 51, 102, 0.3);
}

.badge-info {
    background: rgba(0, 204, 255, 0.15);
    color: var(--info);
    border: 1px solid rgba(0, 204, 255, 0.3);
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: pointer;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 400;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h2 i {
    color: var(--accent);
}

.modal-close {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.5rem;
}

.modal-close:hover {
    background: transparent !important;
    border: none !important;
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-close i {
    font-size: 2.2rem;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.modal-footer button,
.modal-footer a {
    flex: 1;
    justify-content: center;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    margin-bottom: 12px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 22px;
    transition: var(--transition);
}

.slider::before {
    position: absolute;
    content: '';
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

input:checked + .slider {
    background: var(--gradient-primary);
    border-color: transparent;
}

input:checked + .slider::before {
    transform: translateX(18px);
    background: white;
}

/* ============================================
   PROVIDER CARDS
   ============================================ */
.provider-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.provider-card input,
.provider-card select,
.provider-card button {
    border-radius: var(--radius-sm) !important;
}

.provider-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
}

/* Providers Grid - horizontal row */
#page-providers .provider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.provider-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.125rem;
}

.provider-header h3 i {
    color: var(--accent);
    font-size: 1.125rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    color: var(--accent);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ============================================
   IMAGE GENERATION STYLES
   ============================================ */
.image-sizes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
}

.image-styles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* Image Styles - 3x4 Grid */
.image-styles-grid-3x4 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 8px;
}

.image-styles-grid-3x4 .style-btn {
    padding: 8px 6px;
    font-size: 0.8125rem;
    height: 100%;
    min-height: 44px;
}

.image-styles-grid-3x4 .style-btn i {
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.image-styles-grid-3x4 .style-btn span {
    font-size: 0.8125rem;
}

.size-btn, .style-btn {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    min-height: 40px;
    text-align: left;
}

.size-btn::before, .style-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
    transform: scaleY(0);
    transition: var(--transition);
}

.size-btn.active::before, .style-btn.active::before {
    transform: scaleY(1);
}

.size-btn i, .style-btn i {
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 20px;
    text-align: center;
}

.size-btn span, .style-btn span {
    font-size: 0.9375rem;
    font-weight: 400;
}

.size-btn small {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.size-btn:hover, .style-btn:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
}

.size-btn.active, .style-btn.active {
    border: 1px solid var(--accent);
    background: var(--bg-tertiary);
    color: var(--accent);
}

.size-btn.active i, .style-btn.active i {
    color: var(--accent);
}

/* Aspect Ratio Cards - Compact Menu Style */
/* Image Settings 3-Column Grid */
.image-settings-grid {
    display: grid;
    grid-template-columns: 200px 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

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

.settings-column > label {
    flex-shrink: 0;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.settings-column > div {
    flex: 1;
}

.settings-column label {
    margin-bottom: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Aspect Ratio - Vertical 1x4 */
.aspect-ratio-vertical {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    gap: 8px;
}

.aspect-ratio-vertical .aspect-card {
    padding: 8px 10px;
    display: flex;
    align-items: center;
}

.aspect-ratio-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.aspect-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: relative;
    overflow: hidden;
    min-height: 40px;
}

.aspect-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
    transform: scaleY(0);
    transition: var(--transition);
}

.aspect-card:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
}

.aspect-card.active {
    border: 1px solid var(--accent);
    background: var(--bg-tertiary);
}

.aspect-card.active::before {
    transform: scaleY(1);
}

.aspect-preview {
    display: none;
}

.aspect-options {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.aspect-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 20px;
    text-align: center;
}

.aspect-card.active .aspect-icon {
    color: var(--accent);
}

/* Segmented Buttons для пропорций */
.aspect-segmented {
    display: flex;
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.segment-btn {
    flex: 1;
    padding: 4px 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.segment-btn.active {
    background: var(--accent);
    color: #0a0a0f;
}

.segment-btn:hover:not(.active) {
    background: rgba(0, 240, 255, 0.1);
    color: var(--text-primary);
}

.switch-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.switch-label span {
    font-weight: 400;
    min-width: 45px;
    text-align: center;
}

.switch-label span:first-child {
    text-align: right;
}

.switch-label span:last-child {
    text-align: left;
}

.switch.small {
    width: 32px;
    height: 18px;
}

.switch.small .slider::before {
    width: 12px;
    height: 12px;
    left: 2px;
    bottom: 2px;
}

.switch.small input:checked + .slider::before {
    transform: translateX(14px);
}

@media (max-width: 1200px) {
    .image-settings-grid {
        grid-template-columns: 180px 1fr 1fr;
        gap: 16px;
    }
}

@media (max-width: 1024px) {
    .image-settings-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .settings-column {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .settings-column label {
        width: 100%;
        margin-bottom: 8px;
    }

    .aspect-ratio-vertical {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
        width: 100%;
    }

    .image-styles-grid-3x4 {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(3, 1fr);
        width: 100%;
    }

    .color-palettes-2x4 {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(2, 1fr);
        width: 100%;
    }

    .aspect-ratio-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .image-styles-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .aspect-ratio-vertical {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }

    .image-styles-grid-3x4 {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }

    .color-palettes-2x4 {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }

    .aspect-ratio-cards {
        grid-template-columns: 1fr;
    }
    .image-styles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Color Palettes with Check */
.palette-btn {
    position: relative;
}

.palette-btn .check-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: var(--bg-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.palette-btn.active .check-icon {
    opacity: 1;
    transform: scale(1);
}

.color-palettes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
}

/* Color Palettes - 2x4 Grid */
.color-palettes-2x4 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 8px;
}

.color-palettes-2x4 .palette-btn {
    height: 100%;
    min-height: 44px;
}

.palette-btn {
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.palette-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
}

.palette-btn span {
    position: relative;
    z-index: 1;
    font-size: 0.8125rem;
    font-weight: 400;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.palette-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    border-color: var(--accent);
}

.palette-btn.active {
    border: 1px solid var(--accent);
}

.image-result {
    text-align: center;
}

.image-result img {
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    border: 1px solid var(--border);
}

.image-actions {
    flex-wrap: wrap;
}

/* ============================================
   LOADING & ANIMATIONS
   ============================================ */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.pe-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

.pulse-animation {
    animation: pulse 2s ease-in-out infinite;
}

/* ============================================
   SIDEBAR SECTIONS
   ============================================ */
.sidebar-section {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Language Dropdown */
.lang-dropdown-container {
    position: relative;
}

.lang-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 300;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.lang-dropdown-toggle:hover {
    border-color: var(--accent);
}

.lang-dropdown-toggle i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.lang-dropdown-toggle.active i {
    transform: rotate(180deg);
}

.lang-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

.lang-dropdown-menu.active {
    max-height: 300px;
    opacity: 1;
    overflow-y: auto;
}

.lang-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 300;
}

.lang-dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.lang-dropdown-item.active {
    background: var(--accent);
    color: var(--bg-primary);
    border: 1px solid var(--accent);
}

.lang-dropdown-item .flag {
    font-size: 16px;
    width: 24px;
    text-align: center;
}

.lang-option-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 300;
}

/* Theme Switcher - Horizontal Compact */
.theme-switch-horizontal {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.theme-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.theme-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.theme-btn.active {
    border: 1px solid var(--accent);
    color: var(--accent);
    background: rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.3);
}

.theme-btn.active[data-theme="neon"] {
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.4);
}

.theme-btn.active[data-theme="warm"] {
    box-shadow: 0 0 15px rgba(255, 149, 0, 0.4);
}

.theme-btn.active[data-theme="fresh"] {
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

.theme-btn.active[data-theme="cool"] {
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.4);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .toast-container {
        left: 24px;
        right: 24px;
        max-width: none;
    }
}

.toast {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-hover);
    animation: slideInLeft 0.4s ease;
    border-left: 4px solid var(--accent);
    pointer-events: auto;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.success { border-left-color: var(--success); }
.toast.info { border-left-color: var(--info); }

.toast i {
    font-size: 1.125rem;
}

.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.success i { color: var(--success); }
.toast.info i { color: var(--info); }

.toast-message {
    flex: 1;
    font-size: 0.9375rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    width: auto;
    font-size: 1.125rem;
    transition: var(--transition);
}

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

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .top-bar {
        margin-left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .stat-card {
        padding: 8px !important;
    }
    
    .stat-icon {
        font-size: 1.25rem !important;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

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

    .list-item {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: var(--bg-primary);
    border: none;
    box-shadow: var(--shadow-lg);
    z-index: 99;
    font-size: 1.5rem;
}

/* ============================================
   UTILITIES
   ============================================ */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hidden { display: none !important; }

.mt-4 { margin-top: 8px; }
.mb-4 { margin-bottom: 12px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
/* Period Filter Buttons */
.period-btn:hover {
    background: var(--accent-muted) !important;
    color: var(--accent) !important;
}
.period-btn.active {
    background: var(--accent) !important;
    color: #fff !important;
    border: 1px solid var(--accent) !important;
}

/* Report Period Buttons */
.report-period-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}
.report-period-btn:hover {
    background: var(--accent-muted);
    color: var(--accent);
}
.report-period-btn.active {
    background: var(--accent) !important;
    color: #fff !important;
    border: 1px solid var(--accent) !important;
}

/* Period Filters Sticky */
.period-filters {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Stat Cards Hover Effects */
.stat-card {
    transition: all 0.3s ease;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-color: var(--accent);
}

/* Topic Cards Hover */
#topics-summary > div {
    transition: all 0.3s ease;
}
#topics-summary > div:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: var(--accent);
}

/* Hashtag Cloud Animations */
#hashtags-cloud span {
    transition: all 0.2s ease;
    cursor: pointer;
}
#hashtags-cloud span:hover {
    transform: scale(1.1);
    background: var(--accent) !important;
    color: #fff !important;
    opacity: 1 !important;
}

/* Data Table */
.data-table {
    font-size: 0.9rem;
}
.data-table th,
.data-table td {
    padding: 10px;
}
.data-table tbody tr {
    transition: background 0.2s ease;
}
.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* Top Articles Animation */
.top-article-item:hover {
    background: rgba(99, 102, 241, 0.08) !important;
    border-radius: var(--radius);
    transform: translateX(4px);
}

/* Chart Bars Animation */
#analytics-chart > div {
    animation: slideUp 0.5s ease forwards;
}
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth content transition */
.stats-grid, #topics-summary, #hashtags-cloud, #top-articles, #analytics-chart {
    animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chart Column Hover */
.chart-column:hover .chart-bar {
    filter: brightness(1.1);
}

/* Loading shimmer effect */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.loading-shimmer {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, rgba(99,102,241,0.1) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ===== Page: Monitoring (Search) ===== */
#page-search .form-group {
    margin-bottom: 12px;
}

#page-search .form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.2;
    min-height: 20px;
}

#page-search .chips-input {
    width: 100%;
    height: 40px;
    margin-top: 10px;
    margin-bottom: 20px;
    padding: 0 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-sizing: border-box;
}

#page-search .chips-container {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    overflow: hidden;
}

#page-search .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    background: var(--accent);
    color: #0a0a0f;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
}

#page-search .chip i {
    font-size: 11px;
    cursor: pointer;
}

#page-search .chips-arrow {
    color: var(--text-secondary);
    font-size: 12px;
}

#page-search .form-group:has(.chips-input) {
    position: relative;
}

#page-search .chips-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

#page-search .chip-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

#page-search .chip-option:last-child {
    border-bottom: none;
}

#page-search .chip-option:hover {
    background: var(--bg-hover);
}

#page-search .chip-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

#page-search .form-control,
#page-search input[type="text"],
#page-search select {
    width: 100%;
    height: 40px;
    box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
}

/* NEO-SEO 3.0 Preview Styles */
.neo-preview {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 8px;
}

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

.neo-section h4 {
    margin: 0 0 12px 0;
    color: var(--accent);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.neo-section h4 i {
    font-size: 16px;
}

/* Core Thesis */
.thesis-card {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
    padding: 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.thesis-item {
    display: flex;
    margin-bottom: 8px;
}

.thesis-item:last-child {
    margin-bottom: 0;
}

.thesis-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 60px;
    font-size: 12px;
    text-transform: uppercase;
}

.thesis-value {
    color: var(--text-primary);
    flex: 1;
}

.thesis-value.metric {
    color: var(--success);
    font-weight: 600;
}

/* Quick Answer */
.quick-answer-box {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    padding: 16px;
    border-radius: var(--radius);
    font-style: italic;
    line-height: 1.6;
}

/* Lead Box */
.lead-box {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius);
    font-style: italic;
    line-height: 1.7;
    color: var(--text-primary);
}

/* Preview Inputs */
.preview-input, .preview-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
}

.preview-textarea {
    resize: vertical;
    min-height: 80px;
}

/* FAQ Preview */
.faq-preview-item {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.faq-preview-item:last-child {
    margin-bottom: 0;
}

.faq-q {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
}

.faq-a {
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 6px;
}

.faq-intent {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

/* Meta Grid */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.meta-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.meta-value {
    font-size: 13px;
    color: var(--text-primary);
}

/* CTA Box */
.cta-box {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-sm);
}

.cta-box div {
    margin-bottom: 8px;
}

.cta-box div:last-child {
    margin-bottom: 0;
}

/* Hashtags */
.hashtags-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hashtag {
    background: var(--accent);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
}

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .meta-grid {
        grid-template-columns: 1fr;
    }
}

</style>
<!-- Markmap for Mindmap Visualization -->
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
<script src="https://cdn.jsdelivr.net/npm/markmap-view@0.18"></script>
<script src="https://cdn.jsdelivr.net/npm/markmap-lib@0.18"></script>
<!-- PDF Generation Libraries -->
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jspdf@2.5.1/dist/jspdf.umd.min.js"></script>
