/* ============================================================
   СБРОС ВНУТРИ #app
   Tailwind подключён с corePlugins.preflight:false и important:'#app'
   (см. links.html), чтобы не задевать остальной сайт/CMS.
   Но без preflight у браузера остаются собственные отступы у
   заголовков/списков/кнопок — здесь их убираем, ТОЛЬКО внутри #app.
   ============================================================ */
#app, #app *, #app *::before, #app *::after {
    box-sizing: border-box;
}
#app h1, #app h2, #app h3, #app h4, #app h5, #app h6,
#app p, #app figure, #app blockquote, #app dl, #app dd {
    margin: 0;
}
#app ul, #app ol {
    margin: 0;
    padding: 0;
    list-style: none;
}
#app button, #app input, #app select, #app textarea {
    font: inherit;
    color: inherit;
    line-height: inherit;
}
#app button {
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}
#app a {
    color: inherit;
    text-decoration: none;
}
#app img, #app svg, #app video, #app canvas {
    display: block;
    max-width: 100%;
}
#app input, #app textarea {
    background: transparent;
    border: 0;
}

/* === БАЗОВЫЕ СТИЛИ === */
#app {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0a0e1a 0%, #0f172a 50%, #141b2d 100%);
    background-attachment: fixed;
    color: #f8fafc;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* Анимированный фон с частицами */
#app::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.03) 0%, transparent 30%),
        radial-gradient(circle at 80% 70%, rgba(249, 115, 22, 0.03) 0%, transparent 30%),
        radial-gradient(circle at 40% 80%, rgba(16, 185, 129, 0.02) 0%, transparent 30%);
    animation: bgFloat 30s ease-in-out infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes bgFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(5%, -5%) rotate(1deg); }
    50% { transform: translate(-3%, 3%) rotate(-1deg); }
    75% { transform: translate(-5%, -3%) rotate(0.5deg); }
}

/* === СКРОЛЛБАР === */
#app ::-webkit-scrollbar { width: 10px; height: 10px; }
#app ::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 10px;
}
#app ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 10px;
    border: 2px solid #0f172a;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}
#app ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

/* === СТЕКЛЯННЫЕ КАРТОЧКИ === */
.glass-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
    backdrop-filter: blur(25px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 20px 60px -15px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 10px 30px rgba(59, 130, 246, 0.1);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.03) 50%,
        transparent 70%);
    transform: rotate(45deg);
    transition: all 0.6s ease;
}

.glass-card:hover::before {
    left: 100%;
}

.glass-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(59, 130, 246, 0.5) 30%,
        rgba(249, 115, 22, 0.5) 70%,
        transparent 100%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.glass-card:hover::after {
    opacity: 1;
}

.glass-card:hover {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow:
        0 30px 80px -20px rgba(0, 0, 0, 0.9),
        0 0 0 1px rgba(59, 130, 246, 0.2) inset,
        0 15px 40px rgba(59, 130, 246, 0.2),
        0 0 50px rgba(59, 130, 246, 0.1);
    transform: translateY(-5px) scale(1.01);
}

/* === ЭФФЕКТ СВЕЧЕНИЯ === */
.glow-text {
    text-shadow:
        0 0 10px currentColor,
        0 0 20px currentColor,
        0 0 40px currentColor,
        0 0 80px currentColor;
    animation: pulse-glow 2s ease-in-out infinite;
    filter: brightness(1.2);
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        text-shadow:
            0 0 10px currentColor,
            0 0 20px currentColor,
            0 0 40px currentColor,
            0 0 80px currentColor;
    }
    50% {
        opacity: 0.9;
        text-shadow:
            0 0 15px currentColor,
            0 0 30px currentColor,
            0 0 60px currentColor,
            0 0 120px currentColor;
    }
}

/* === АНИМАЦИЯ ПОЯВЛЕНИЯ === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.glass-card {
    animation: fadeInUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.glass-card:nth-child(1) { animation-delay: 0.05s; }
.glass-card:nth-child(2) { animation-delay: 0.1s; }
.glass-card:nth-child(3) { animation-delay: 0.15s; }
.glass-card:nth-child(4) { animation-delay: 0.2s; }
.glass-card:nth-child(5) { animation-delay: 0.25s; }
.glass-card:nth-child(6) { animation-delay: 0.3s; }

/* === ГРАДИЕНТНЫЕ БЛИКИ В КАРТОЧКАХ === */
.glass-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.03) 50%,
        transparent 70%);
    transform: rotate(45deg);
    transition: all 0.6s ease;
}

.glass-card:hover::before {
    left: 100%;
}

/* === КНОПКИ === */
#app button, #app .cursor-pointer {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#app button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.8s, height 0.8s;
}

#app button:active::before {
    width: 400px;
    height: 400px;
}

#app button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

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

/* === УЛУЧШЕННЫЕ ПРОГРЕСС-БАРЫ === */
.glass-card .bg-brand-orange,
.glass-card .bg-brand-blue,
.glass-card .bg-green-500 {
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px currentColor;
}

.glass-card .bg-brand-orange::after,
.glass-card .bg-brand-blue::after,
.glass-card .bg-green-500::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%);
    animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
    to { left: 200%; }
}

/* Дополнительный эффект пульсации */
.glass-card .bg-brand-orange,
.glass-card .bg-brand-blue,
.glass-card .bg-green-500 {
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% {
        box-shadow: 0 0 20px currentColor;
    }
    50% {
        box-shadow: 0 0 30px currentColor, 0 0 50px currentColor;
    }
}

/* === УЛУЧШЕННАЯ ТИПОГРАФИКА === */
#app h1, #app h2, #app h3, #app h4, #app h5, #app h6 {
    font-weight: 900;
    letter-spacing: -0.03em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* === АНИМАЦИЯ ЧИСЕЛ === */
@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(0.3) rotateX(-90deg);
        filter: blur(10px);
    }
    60% {
        transform: scale(1.1) rotateX(10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateX(0);
        filter: blur(0);
    }
}

.glass-card h3 {
    animation: countUp 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    transform-style: preserve-3d;
}

/* === ТЕНИ ДЛЯ ИКОНОК === */
#app .fa-solid {
    filter: drop-shadow(0 4px 12px currentColor);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.glass-card:hover .fa-solid {
    filter: drop-shadow(0 8px 20px currentColor) drop-shadow(0 0 30px currentColor);
    transform: scale(1.15) rotate(5deg);
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: scale(1.15) rotate(5deg) translateY(0); }
    50% { transform: scale(1.15) rotate(5deg) translateY(-5px); }
}

/* === УЛУЧШЕННЫЕ ЦВЕТНЫЕ БЛИКИ === */
.glass-card .absolute.blur-3xl,
.glass-card .absolute.blur-2xl {
    transition: all 0.8s ease;
    animation: float 8s ease-in-out infinite;
    filter: blur(60px);
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
    25% { transform: translate(15px, -15px) scale(1.2) rotate(5deg); }
    50% { transform: translate(-10px, 10px) scale(0.9) rotate(-5deg); }
    75% { transform: translate(-15px, -10px) scale(1.1) rotate(3deg); }
}

.glass-card:hover .absolute.blur-3xl,
.glass-card:hover .absolute.blur-2xl {
    opacity: 0.6 !important;
    transform: scale(1.8);
    filter: blur(80px);
}

/* === ТАБЛИЦА === */
#app table tbody tr {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

#app table tbody tr::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 0%;
    background: linear-gradient(180deg, #3b82f6, #60a5fa);
    transition: height 0.4s ease;
}

#app table tbody tr:hover::before {
    height: 100%;
}

#app table tbody tr:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0.05) 100%) !important;
    transform: translateX(8px) scale(1.01);
    box-shadow: -5px 0 20px rgba(59, 130, 246, 0.2);
}

/* === NAVBAR АКТИВНЫЕ КНОПКИ === */
#app nav button {
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

#app nav button::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 4px;
    height: 0;
    background: linear-gradient(180deg, #3b82f6, #60a5fa);
    transform: translateY(-50%);
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 10px 10px 0;
    box-shadow: 0 0 15px #3b82f6;
}

#app nav button[class*="bg-brand-blue"]::after {
    height: 70%;
}

#app nav button[class*="bg-brand-blue"] {
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3);
}

#app nav button:hover {
    transform: translateX(5px);
}

/* === УЛУЧШЕННЫЕ ТОСТЫ === */
#app #toast-container > div {
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    animation: toastSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toastSlideIn {
    from {
        transform: translateX(400px) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* === NO SCROLLBAR === */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* === ПЛАВНЫЕ И ЭФФЕКТНЫЕ АНИМАЦИИ === */

/* Главная анимация вкладки */
.tab-animate {
    animation: smoothTabEnter 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
    transform-style: preserve-3d;
}

@keyframes smoothTabEnter {
    0% {
        opacity: 0;
        transform: translateY(60px) scale(0.9) rotateX(10deg);
        filter: blur(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0);
        filter: blur(0);
    }
}

/* Каскадные анимации для элементов */
.tab-animate > div:nth-child(1) {
    animation: slideUpBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s backwards !important;
}

.tab-animate > div:nth-child(2) {
    animation: slideUpBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s backwards !important;
}

.tab-animate > div:nth-child(3) {
    animation: slideUpBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s backwards !important;
}

.tab-animate > div:nth-child(4) {
    animation: slideUpBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s backwards !important;
}

.tab-animate > div:nth-child(5) {
    animation: slideUpBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s backwards !important;
}

@keyframes slideUpBounce {
    0% {
        opacity: 0;
        transform: translateY(80px) scale(0.8);
        filter: blur(15px);
    }
    60% {
        transform: translateY(-12px) scale(1.03);
        filter: blur(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Анимация для grid карточек */
.tab-animate .grid > div {
    animation: cardExpand 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) backwards !important;
}

.tab-animate .grid > div:nth-child(1) { animation-delay: 0.1s !important; }
.tab-animate .grid > div:nth-child(2) { animation-delay: 0.15s !important; }
.tab-animate .grid > div:nth-child(3) { animation-delay: 0.2s !important; }
.tab-animate .grid > div:nth-child(4) { animation-delay: 0.25s !important; }

@keyframes cardExpand {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(60px) rotateY(-15deg);
        filter: blur(20px);
    }
    50% {
        transform: scale(1.1) translateY(-10px) rotateY(5deg);
        filter: blur(5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0) rotateY(0);
        filter: blur(0);
    }
}

/* === ГРАФИКИ === */
#app canvas {
    filter: drop-shadow(0 15px 40px rgba(0, 0, 0, 0.5));
    transition: all 0.5s ease;
}

#app canvas:hover {
    filter: drop-shadow(0 20px 50px rgba(59, 130, 246, 0.3));
    transform: scale(1.02);
}

/* === АНИМАЦИЯ ЗАГРУЗКИ ГРАФИКОВ === */
@keyframes chartFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) rotateX(10deg);
        filter: blur(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateX(0);
        filter: blur(0);
    }
}

#app canvas {
    animation: chartFadeIn 1s cubic-bezier(0.22, 1, 0.36, 1);
    transform-style: preserve-3d;
}

/* === УЛУЧШЕННЫЙ HEADER === */
#app header {
    backdrop-filter: blur(25px) saturate(200%);
    box-shadow:
        0 4px 30px -10px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    background: linear-gradient(90deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

/* === УЛУЧШЕННЫЙ SIDEBAR === */
#app aside {
    backdrop-filter: blur(25px) saturate(200%);
    box-shadow:
        4px 0 30px -10px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
}

/* === СЕЛЕКТЫ === */
#app select {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#app select:hover {
    background: linear-gradient(135deg, rgba(51, 65, 85, 0.9) 0%, rgba(30, 41, 59, 0.9) 100%);
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow:
        0 8px 20px rgba(59, 130, 246, 0.3),
        0 0 30px rgba(59, 130, 246, 0.2);
}

#app select:focus {
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.4),
        0 10px 30px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px) scale(1.02);
}

#app select:active {
    transform: translateY(0) scale(0.98);
}

/* Стили для выпадающего списка option */
#app select option {
    background: #1e293b;
    color: #f8fafc;
    padding: 10px;
    font-weight: 500;
}

#app select option:hover,
#app select option:focus,
#app select option:checked {
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    font-weight: 600;
}

/* === MICRO INTERACTIONS === */
.tracking-widest,
.uppercase {
    transition: all 0.4s ease;
}

.glass-card:hover .tracking-widest {
    letter-spacing: 0.18em;
    text-shadow: 0 0 10px currentColor;
}

/* === ДОПОЛНИТЕЛЬНЫЕ ЭФФЕКТЫ === */

/* Свечение для статусов и бейджей */
.bg-brand-orange\/10,
.bg-orange-500\/10,
.bg-green-400,
.text-brand-blue {
    position: relative;
}

.bg-brand-orange\/10:hover,
.bg-orange-500\/10:hover {
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.3);
}

/* Улучшенная анимация для чисел при ховере */
.glass-card:hover h3 {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

/* Пульсация для важных элементов */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.02);
    }
}

.text-brand-green.glow-text {
    animation: pulse 2s ease-in-out infinite;
}

/* Gradient border animation для активных элементов */
@keyframes borderGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(59, 130, 246, 0.6);
    }
}

#app nav button[class*="bg-brand-blue"] {
    animation: borderGlow 3s ease-in-out infinite;
}

/* Эффект параллакса для больших карточек */
.glass-card.lg\:col-span-2 {
    transition: transform 0.3s ease;
}

.glass-card.lg\:col-span-2:hover {
    transform: perspective(1000px) rotateX(2deg) translateY(-5px);
}

/* Ripple эффект для всех кликабельных элементов */
@keyframes ripple {
    to {
        transform: scale(2.5);
        opacity: 0;
    }
}

#app button:active::after,
#app .cursor-pointer:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    animation: ripple 0.6s ease-out;
}

/* === RESPONSIVE IMPROVEMENTS === */
@media (max-width: 768px) {
    .glass-card {
        backdrop-filter: blur(15px);
    }

    .glass-card:hover {
        transform: translateY(0);
    }
}
