/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #007bff;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --dark: #343a40;
    --light: #f8f9fa;
    --border: #dee2e6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--light);
    overflow-x: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Загрузка */
#loading-screen {
    justify-content: center;
    align-items: center;
    background: var(--primary);
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Экран входа */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.container {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.logo {
    font-size: 60px;
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark);
    font-size: 24px;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
    font-size: 14px;
}

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Кнопки */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #0056b3;
}

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

.btn-large {
    padding: 16px 24px;
    font-size: 18px;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

/* Сообщения */
.error, .success {
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    text-align: center;
}

.error {
    background: #f8d7da;
    color: #721c24;
}

.success {
    background: #d4edda;
    color: #155724;
}

.hidden {
    display: none !important;
}

/* Главный экран */
#main-screen {
    background: var(--light);
}

.app-header {
    background: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    margin: 0;
    font-size: 20px;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sync-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    background: var(--light);
}

.sync-status.synced {
    background: #d4edda;
    color: #155724;
}

.sync-status.syncing {
    background: #fff3cd;
    color: #856404;
}

.sync-status.offline {
    background: #f8d7da;
    color: #721c24;
}

/* Навигация */
.app-nav {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border);
}

.nav-btn {
    flex: 1;
    padding: 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-btn.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

/* Контент */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Транзакции */
.filters {
    margin-bottom: 20px;
}

/* Пагинация */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 14px;
    color: #666;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.form-control-small {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    min-width: 60px;
    background: white;
}

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

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

.transaction-item {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.transaction-item:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.transaction-item.pending {
    border-left: 4px solid var(--warning);
}

.transaction-item.synced {
    border-left: 4px solid var(--success);
}

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

.transaction-type {
    font-weight: 600;
    font-size: 14px;
}

.transaction-type.income {
    color: var(--success);
}

.transaction-type.expense {
    color: var(--danger);
}

.transaction-amount {
    font-size: 18px;
    font-weight: 700;
}

.transaction-status-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.transaction-status {
    font-size: 12px;
    color: #666;
}

.transaction-details {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
}

/* Оффлайн баннер */
.offline-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--warning);
    color: #856404;
    padding: 12px;
    text-align: center;
    font-weight: 600;
    z-index: 1000;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
}

/* Индикатор соединения */
.connection-status {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
    color: #666;
}

/* Адаптивность */
@media (max-width: 768px) {
    .app-content {
        padding: 12px;
    }
    
    .container {
        padding: 20px;
    }
}

/* Модальные окна */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* Кнопка удаления в транзакции */
.transaction-delete {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all 0.3s;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.transaction-delete:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.transaction-delete:active {
    transform: scale(0.95);
}

/* Карточка транзакции */
.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 0;
    font-size: 20px;
    flex: 1;
}

/* iOS специфичные стили */
@supports (-webkit-touch-callout: none) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .app-header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
}


