/* ===== ПЕРЕМЕННЫЕ ===== */
:root {
    /* Цвета */
    --primary: #6C63FF;
    --primary-light: #8B85FF;
    --primary-dark: #5A52D5;
    --secondary: #FF6584;
    --success: #2ECC71;
    --warning: #F39C12;
    --danger: #E74C3C;
    --info: #3498DB;
    
    /* Нейтральные */
    --bg: #0F0F23;
    --bg-2: #1A1A35;
    --bg-3: #252545;
    --surface: rgba(255,255,255,0.05);
    --surface-2: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.1);
    --border-hover: rgba(255,255,255,0.2);
    
    /* Текст */
    --text-1: #FFFFFF;
    --text-2: rgba(255,255,255,0.7);
    --text-3: rgba(255,255,255,0.4);
    
    /* Размеры */
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    
    /* Отступы */
    --gap: 16px;
    --gap-sm: 8px;
    --gap-lg: 24px;
    
    /* Тени */
    --shadow: 0 8px 32px rgba(0,0,0,0.3);
    --shadow-sm: 0 4px 16px rgba(0,0,0,0.2);
    --shadow-glow: 0 0 40px rgba(108,99,255,0.3);
    
    /* Анимации */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    
    /* Навигация */
    --nav-height: 70px;
}

/* Светлая тема */
.light-theme {
    --bg: #F0F2FF;
    --bg-2: #E8EAFF;
    --bg-3: #DDE0FF;
    --surface: rgba(255,255,255,0.7);
    --surface-2: rgba(255,255,255,0.9);
    --border: rgba(108,99,255,0.15);
    --border-hover: rgba(108,99,255,0.3);
    --text-1: #1A1A2E;
    --text-2: rgba(26,26,46,0.7);
    --text-3: rgba(26,26,46,0.4);
    --shadow: 0 8px 32px rgba(108,99,255,0.15);
}

/* ===== СБРОС И BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 
                 'SF Pro Display', 'Segoe UI', 
                 Roboto, 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text-1);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== СКРОЛЛБАР ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { 
    background: var(--primary); 
    border-radius: 3px; 
}

/* ===== ЛЕЙАУТ ПРИЛОЖЕНИЯ ===== */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: var(--nav-height);
}

.app-content {
    flex: 1;
    padding: var(--gap);
    max-width: 100%;
    animation: fadeIn 0.3s ease;
}

/* ===== НИЖНЯЯ НАВИГАЦИЯ ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: rgba(15, 15, 35, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0 var(--gap-sm);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    min-width: 60px;
    text-align: center;
}

.nav-item .nav-icon {
    font-size: 22px;
    line-height: 1;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px var(--primary));
}

/* FAB кнопка добавления */
.nav-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 20px rgba(108,99,255,0.5);
    transition: var(--transition);
    margin-top: -10px;
    -webkit-tap-highlight-color: transparent;
}

.nav-fab:hover { transform: scale(1.1); }
.nav-fab:active { transform: scale(0.95); }
.nav-fab .fab-icon { font-size: 28px; color: white; }

/* ===== КАРТОЧКИ ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: var(--gap);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--gap);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
}

/* ===== КНОПКИ ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 15px rgba(108,99,255,0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(108,99,255,0.6);
    transform: translateY(-1px);
}

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

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #C0392B);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #27AE60);
    color: white;
}

.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-icon { padding: 10px; border-radius: 50%; }

/* ===== ФОРМЫ ===== */
.form-group {
    margin-bottom: var(--gap);
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon .icon {
    position: absolute;
    left: 14px;
    font-size: 18px;
    z-index: 1;
    pointer-events: none;
}

.input-icon input,
.input-icon select {
    padding-left: 46px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-1);
    font-size: 16px;
    font-family: inherit;
    transition: var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
    background: var(--surface);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-3);
}

/* Переключатель типа транзакции */
.type-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-2);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: var(--gap);
}

.type-btn {
    flex: 1;
    padding: 10px;
    border-radius: calc(var(--radius) - 4px);
    border: none;
    background: none;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.type-btn.active[data-type="expense"] {
    background: var(--danger);
    color: white;
}

.type-btn.active[data-type="income"] {
    background: var(--success);
    color: white;
}

.type-btn.active[data-type="transfer"] {
    background: var(--info);
    color: white;
}

/* ===== СУММА (БОЛЬШОЙ ВВОД) ===== */
.amount-input-wrap {
    text-align: center;
    padding: 20px 0;
}

.amount-display {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -2px;
    min-height: 60px;
    cursor: text;
}

.amount-display.expense { color: var(--danger); }
.amount-display.income  { color: var(--success); }

.amount-currency {
    font-size: 24px;
    color: var(--text-3);
}

/* ===== КАЛЬКУЛЯТОР ===== */
.calculator {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 16px;
}

.calc-btn {
    padding: 18px 10px;
    border-radius: var(--radius);
    border: none;
    background: var(--surface);
    color: var(--text-1);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.calc-btn:active { transform: scale(0.93); }

.calc-btn.operator { 
    background: rgba(108,99,255,0.2); 
    color: var(--primary-light); 
}

.calc-btn.ok { 
    background: var(--primary); 
    color: white;
    grid-row: span 2;
}

.calc-btn.zero { grid-column: span 2; }

/* ===== СПИСОК ТРАНЗАКЦИЙ ===== */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: var(--transition-fast);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.transaction-item:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.transaction-item:active {
    transform: scale(0.99);
}

.tx-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

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

.tx-category {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-desc {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

.tx-amount {
    font-size: 16px;
    font-weight: 700;
    text-align: right;
    flex-shrink: 0;
}

.tx-amount.expense { color: var(--danger); }
.tx-amount.income  { color: var(--success); }
.tx-amount.transfer { color: var(--info); }

.tx-date-label {
    padding: 16px 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== КАРТОЧКИ СЧЕТОВ ===== */
.accounts-scroll {
    display: flex;
    gap: var(--gap-sm);
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.accounts-scroll::-webkit-scrollbar { display: none; }

.account-card {
    flex-shrink: 0;
    width: 180px;
    padding: 16px;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.account-card-bg {
    position: absolute;
    inset: 0;
    opacity: 0.15;
    border-radius: inherit;
}

.account-card-name {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
    margin-bottom: 4px;
}

.account-card-balance {
    font-size: 20px;
    font-weight: 800;
    color: white;
}

.account-card-type {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-top: 8px;
}

.account-card-icon {
    position: absolute;
    right: 12px;
    top: 12px;
    font-size: 28px;
    opacity: 0.6;
}

/* ===== ПРОГРЕСС БЮДЖЕТА ===== */
.budget-progress {
    margin-bottom: 12px;
}

.budget-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 14px;
}

.budget-name {
    color: var(--text-1);
    font-weight: 600;
}

.budget-amounts {
    color: var(--text-2);
}

.progress-bar {
    height: 8px;
    background: var(--bg-2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.progress-fill.warning {
    background: linear-gradient(90deg, var(--warning), #E67E22);
}

.progress-fill.danger {
    background: linear-gradient(90deg, var(--danger), #C0392B);
}

/* ===== ДАШБОРД БАЛАНС ===== */
.balance-widget {
    text-align: center;
    padding: 30px 20px;
    position: relative;
    overflow: hidden;
}

.balance-label {
    font-size: 13px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.balance-amount {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.balance-stats {
    display: flex;
    gap: var(--gap);
    justify-content: center;
    margin-top: 16px;
}

.balance-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.balance-stat-label {
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.balance-stat-value {
    font-size: 16px;
    font-weight: 700;
}

.balance-stat-value.income-color { color: var(--success); }
.balance-stat-value.expense-color { color: var(--danger); }

/* ===== АЛЕРТЫ ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: var(--gap);
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: rgba(231,76,60,0.15);
    border: 1px solid rgba(231,76,60,0.3);
    color: #FF8A7A;
}

.alert-success {
    background: rgba(46,204,113,0.15);
    border: 1px solid rgba(46,204,113,0.3);
    color: #5CFF9D;
}

.alert-warning {
    background: rgba(243,156,18,0.15);
    border: 1px solid rgba(243,156,18,0.3);
    color: #FFB84D;
}

/* ===== ЧИПЫ / ТЕГИ ===== */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--surface-2);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.chip:hover,
.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ===== ПУСТОЕ СОСТОЯНИЕ ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3);
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: 16px;
    filter: grayscale(0.3);
}

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

.empty-state p {
    font-size: 14px;
}

/* ===== МОДАЛЬНЫЕ ОКНА ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.center {
    align-items: center;
    padding: var(--gap);
}

.modal {
    background: var(--bg-2);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-height: 95vh;
    overflow-y: auto;
    padding: 24px;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.center {
    border-radius: var(--radius-xl);
    max-width: 480px;
    margin: auto;
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: -12px auto 20px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--gap);
}

/* ===== СВАЙП ДЕЙСТВИЯ ===== */
.swipe-wrapper {
    position: relative;
    overflow: hidden;
}

.swipe-actions {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: var(--bg-2);
    border-radius: var(--radius-sm);
}

/* ===== ЗАГРУЗКА ===== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface) 25%,
        var(--surface-2) 50%,
        var(--surface) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

/* ===== ЛОГИН СТРАНИЦА ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
}

.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: blobFloat 8s ease-in-out infinite;
}

.blob-1 {
    width: 400px; height: 400px;
    background: var(--primary);
    top: -100px; left: -100px;
    animation-delay: 0s;
}

.blob-2 {
    width: 300px; height: 300px;
    background: var(--secondary);
    top: 50%; right: -80px;
    animation-delay: 3s;
}

.blob-3 {
    width: 250px; height: 250px;
    background: #00D4FF;
    bottom: -80px; left: 30%;
    animation-delay: 6s;
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: var(--gap);
}

.login-card {
    padding: 40px 32px;
}

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

.logo-icon {
    font-size: 56px;
    display: block;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 20px rgba(108,99,255,0.5));
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 14px;
    color: var(--text-3);
}

.login-form .btn {
    margin-top: 8px;
}

.toggle-password {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

/* ===== ЗАГОЛОВОК СТРАНИЦЫ ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 8px;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
}

/* ===== АНИМАЦИИ ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(20px, -30px) scale(1.05); }
    66% { transform: translate(-15px, 20px) scale(0.95); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 375px) {
    :root { --gap: 12px; }
    .balance-amount { font-size: 34px; }
}

@media (min-width: 768px) {
    .app-layout {
        flex-direction: row;
        padding-bottom: 0;
    }
    
    .bottom-nav {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 240px;
        flex-direction: column;
        justify-content: flex-start;
        padding: 24px 12px;
        border-right: 1px solid var(--border);
        border-top: none;
        height: 100vh;
    }
    
    .nav-item {
        flex-direction: row;
        width: 100%;
        padding: 12px 16px;
        gap: 12px;
        font-size: 14px;
    }
    
    .nav-fab {
        width: 100%;
        border-radius: var(--radius);
        margin: 8px 0;
        padding: 14px;
        height: auto;
    }
    
    .app-content {
        margin-left: 240px;
        max-width: 900px;
        padding: 24px;
    }
}