/* Глобальные стили */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --gray-color: #95a5a6;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    color: var(--dark-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Навигация */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--box-shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
}

@media (max-width: 1200px) {
    .navbar .container {
        gap: 0.5rem;
    }
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary-color);
    white-space: nowrap;
}

.nav-brand i {
    font-size: 1.8rem;
}

@media (max-width: 768px) {
    .nav-brand {
        font-size: 1.1rem;
    }
    
    .nav-brand i {
        font-size: 1.5rem;
    }
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow-x: visible;
    scrollbar-width: auto;
}
.nav-menu::-webkit-scrollbar { display: initial; }

.nav-menu li {
    flex-shrink: 0;
}

.nav-menu a {
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 500;
    transition: var(--transition);
    padding: 0.6rem 1rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    white-space: nowrap;
}

.nav-menu a i {
    font-size: 1.1rem;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
}

/* Адаптивность навигации */
@media (max-width: 1024px) {
    .nav-menu a {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .nav-menu a .nav-text {
        display: inline;
    }
}

@media (max-width: 768px) {
    /* держим всё в один ряд, но скрываем текст пунктов */
    .nav-menu a .nav-text { display: none; }
    .nav-user-meta { display: none; }
}

/* User badge in navbar */
.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 12px;
    flex-shrink: 0;
    position: relative;
}

.nav-user-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 0;
    padding: 6px 10px;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.nav-user-btn:hover {
    background: rgba(74, 144, 226, 0.08);
}

.nav-user-caret {
    color: #7f8c8d;
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.nav-user.open .nav-user-caret {
    transform: rotate(180deg);
}

.nav-user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 220px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.18);
    padding: 8px;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 200;
}

.nav-user.open .nav-user-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.nav-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 600;
}

.nav-user-item:hover {
    background: rgba(74, 144, 226, 0.10);
}

.nav-user-sep {
    height: 1px;
    background: rgba(0,0,0,0.06);
    margin: 6px 4px;
}

.nav-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    object-fit: cover;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a90e2;
}

.nav-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.nav-user-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #2c3e50;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-sub {
    font-size: 0.82rem;
    color: #7f8c8d;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .nav-user-meta { display: none; }
}

/* ===== Auth (login/register) ===== */
.navbar-guest .container {
    justify-content: center;
}

.navbar-guest .nav-brand {
    justify-content: center;
}

.nav-guest-actions {
    margin-left: auto;
}

.btn-sm {
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
}

.auth-page {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.2rem 0 3rem;
    width: 100%;
}

.auth-card {
    width: 100%;
    max-width: 520px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.18);
    border: 1px solid rgba(255,255,255,0.35);
    padding: 2.2rem 2.2rem 1.6rem;
}

@media (min-height: 860px) {
    /* На высоких экранах чуть опускаем карточку — без “гигантских” пустот */
    .auth-page {
        padding-top: 2.2rem;
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 1.6rem;
}

.auth-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.75rem;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(74,144,226,0.16) 0%, rgba(53,122,189,0.10) 100%);
    box-shadow: 0 10px 26px rgba(74, 144, 226, 0.18);
    color: var(--primary-color);
}

.auth-header h1 {
    font-size: 1.9rem;
    margin-bottom: 0.35rem;
    color: var(--dark-color);
}

.auth-alert {
    border-radius: 14px;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.98rem;
}

.auth-alert-error {
    background: rgba(231, 76, 60, 0.10);
    border: 1px solid rgba(231, 76, 60, 0.22);
    color: #b71c1c;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.auth-field {
    position: relative;
}

.auth-field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a90e2;
    border: 1px solid rgba(0,0,0,0.06);
    z-index: 2; /* иконка всегда поверх поля */
}

.auth-input {
    width: 100%;
    border: 2px solid #e1e8ed;
    border-radius: 14px;
    padding: 1rem 1.1rem 1rem 62px;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #eef2f6 100%);
    transition: all 0.25s ease;
    font-family: inherit;
    position: relative;
    z-index: 1;
}

.auth-input:hover {
    border-color: rgba(74, 144, 226, 0.65);
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
    box-shadow: 0 10px 24px rgba(74, 144, 226, 0.14);
    transform: translateY(-1px);
}

.auth-input:focus {
    outline: none;
    border-color: #4a90e2;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.14);
}

.auth-field:hover .auth-field-icon,
.auth-field:focus-within .auth-field-icon {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border-color: rgba(74, 144, 226, 0.35);
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(74, 144, 226, 0.22);
}

.auth-field:hover .auth-field-icon i,
.auth-field:focus-within .auth-field-icon i {
    color: #ffffff;
}

.auth-submit {
    width: 100%;
    justify-content: center;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.auth-footer {
    margin-top: 1rem;
    text-align: center;
    color: #7f8c8d;
}

.auth-footer a {
    color: #357abd;
    font-weight: 700;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Основной контент */
.main-content {
    flex: 1 0 auto;
    padding: 2rem 0;
}

/* Секция загрузки */
.upload-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
}

.upload-header {
    text-align: center;
    margin-bottom: 2rem;
}

.upload-header h1 {
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--gray-color);
    font-size: 1.1rem;
}

.upload-area {
    border: 3px dashed var(--primary-color);
    border-radius: var(--border-radius);
    padding: 3rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--secondary-color);
    background: rgba(74, 144, 226, 0.05);
}

.upload-area.drag-over {
    border-color: var(--secondary-color);
    background: rgba(80, 200, 120, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-text h3 {
    color: var(--dark-color);
    margin-bottom: 1rem;
}

.upload-text p {
    color: var(--gray-color);
    margin: 1rem 0;
}

.upload-info {
    margin-top: 1.5rem;
    color: var(--gray-color);
    font-size: 0.9rem;
}

/* Процесс обработки */
.processing {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--light-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Кнопки */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

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

.btn-primary:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

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

.btn-success:hover {
    background: #45b369;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(80, 200, 120, 0.3);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Результаты */
.results-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
}

.results-header {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--secondary-color);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background: white;
    border: 1px solid var(--light-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header i {
    font-size: 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

.file-name {
    font-weight: bold;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.changes-info {
    color: var(--gray-color);
    margin-bottom: 1rem;
}

/* Проблемы */
.issues-section,
.fields-section {
    margin: 2rem 0;
}

.issues-section h3,
.fields-section h3 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-color);
}

.issue-item {
    background: white;
    border-left: 4px solid var(--warning-color);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.issue-item.critical {
    border-left-color: var(--danger-color);
}

.issue-item.important {
    border-left-color: var(--warning-color);
}

.issue-item.low {
    border-left-color: var(--gray-color);
}

.issue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.issue-title {
    font-weight: bold;
    color: var(--dark-color);
}

.issue-severity {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
}

.issue-severity.critical {
    background: var(--danger-color);
}

.issue-severity.important {
    background: var(--warning-color);
}

.issue-severity.low {
    background: var(--gray-color);
}

.issue-description {
    color: var(--gray-color);
    margin-bottom: 0.5rem;
}

.issue-recommendation {
    color: var(--secondary-color);
    font-style: italic;
}

/* Поля */
.field-item {
    background: rgba(74, 144, 226, 0.05);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--primary-color);
}

.field-name {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.field-location {
    color: var(--gray-color);
    font-size: 0.9rem;
}

/* Действия */
.action-buttons {
    margin-top: 2rem;
    text-align: center;
}

/* Настройки */
.settings-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
}

.settings-header {
    text-align: center;
    margin-bottom: 2rem;
}

.settings-form {
    max-width: 800px;
    margin: 0 auto;
}

.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(74, 144, 226, 0.02);
    border-radius: var(--border-radius);
}

.form-section h3 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    color: var(--dark-color);
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group input {
    padding: 0.75rem;
    border: 2px solid var(--light-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-actions {
    text-align: center;
    margin-top: 2rem;
}

/* Алерты */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.alert i {
    font-size: 1.5rem;
}

.alert-info {
    background: rgba(74, 144, 226, 0.1);
    border-left: 4px solid var(--primary-color);
    color: var(--dark-color);
}

.alert-success {
    background: rgba(80, 200, 120, 0.1);
    border-left: 4px solid var(--secondary-color);
    color: var(--dark-color);
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    border-left: 4px solid var(--danger-color);
    color: var(--dark-color);
}

/* Footer */
.footer {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem 0;
    text-align: center;
    color: var(--gray-color);
    margin-top: auto;
}

/* Адаптивность для планшетов */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .nav-menu {
        gap: 1.5rem;
        font-size: 0.95rem;
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 0 10px;
    }
    
    /* Навигация */
    .navbar {
        padding: 0.75rem 0;
    }
    
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-brand {
        font-size: 1.25rem;
    }
    
    .nav-brand i {
        font-size: 1.5rem;
    }
    
    .nav-menu {
        gap: 0.75rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-menu a {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Основной контент */
    .main-content {
        padding: 1rem 0;
    }
    
    /* Секция загрузки */
    .upload-section {
        padding: 1.5rem 1rem;
        margin-bottom: 1rem;
    }
    
    .upload-header h1 {
        font-size: 1.5rem;
    }
    
    .upload-header h1 i {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.95rem;
    }
    
    .upload-area {
        padding: 1.5rem 1rem;
        border-width: 2px;
    }
    
    .upload-icon {
        font-size: 3rem;
        margin-bottom: 0.75rem;
    }
    
    .upload-text h3 {
        font-size: 1.1rem;
    }
    
    .upload-info {
        font-size: 0.85rem;
        margin-top: 1rem;
    }
    
    /* Кнопки */
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.95rem;
    }
    
    .btn-lg {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Результаты */
    .results-section {
        padding: 1.5rem 1rem;
    }
    
    .results-header h2 {
        font-size: 1.4rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card-header {
        padding: 0.75rem;
    }
    
    .card-header h3 {
        font-size: 1rem;
    }
    
    .card-header i {
        font-size: 1.2rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Проблемы и поля */
    .issues-section h3,
    .fields-section h3 {
        font-size: 1.1rem;
    }
    
    .issue-item {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .issue-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .issue-title {
        font-size: 0.95rem;
    }
    
    .issue-severity {
        padding: 0.2rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .field-item {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    /* Настройки */
    .settings-section {
        padding: 1.5rem 1rem;
    }
    
    .form-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .form-section h3 {
        font-size: 1.1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .form-group input {
        padding: 0.6rem;
        font-size: 0.95rem;
    }
    
    /* Токены */
    .tokens-section {
        padding: 1.5rem 1rem;
        margin: 1rem 0;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    .refill-section {
        padding: 1rem;
    }
    
    .refill-section h2 {
        font-size: 1.2rem;
    }
    
    .refill-form {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .refill-form input {
        width: 100%;
        min-width: auto;
    }
    
    .history-section h2 {
        font-size: 1.2rem;
    }
    
    .history-table {
        font-size: 0.8rem;
        display: block;
    }
    
    .history-table thead {
        display: none;
    }
    
    .history-table tbody {
        display: block;
    }
    
    .history-table tr {
        display: block;
        margin-bottom: 1rem;
        padding: 0.75rem;
        background: white;
        border: 1px solid var(--light-color);
        border-radius: var(--border-radius);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    }
    
    .history-table td {
        display: block;
        text-align: left !important;
        padding: 0.5rem 0;
        border: none;
    }
    
    .history-table td:before {
        content: attr(data-label);
        font-weight: bold;
        display: inline-block;
        min-width: 100px;
        color: var(--dark-color);
    }
    
    .action-buttons {
        margin-top: 1.5rem;
    }
    
    /* Footer */
    .footer {
        padding: 1.5rem 0;
        font-size: 0.9rem;
    }
}

/* Адаптивность для маленьких мобильных */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }
    
    .nav-brand {
        font-size: 1.1rem;
    }
    
    .nav-menu {
        gap: 0.5rem;
    }
    
    .nav-menu a {
        font-size: 0.85rem;
        padding: 0.35rem 0.65rem;
    }
    
    .upload-section,
    .results-section,
    .settings-section,
    .tokens-section {
        padding: 1rem 0.75rem;
        border-radius: 6px;
    }
    
    .upload-header h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .upload-area {
        padding: 1.25rem 0.75rem;
    }
    
    .upload-icon {
        font-size: 2.5rem;
    }
    
    .btn {
        padding: 0.55rem 1rem;
        font-size: 0.9rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .issue-title {
        font-size: 0.9rem;
    }
}




/* Страница токенов */
.tokens-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: var(--box-shadow);
}

.page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.stat-card.balance-card {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.9;
}

.stat-info h3 {
    font-size: 0.9rem;
    font-weight: normal;
    opacity: 0.9;
    margin-bottom: 0.5rem;
    color: white;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    margin: 0.5rem 0;
    color: white !important; /* Всегда белый текст */
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.8;
    color: white;
}

/* Пополнение баланса */
.refill-section {
    background: var(--light-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.refill-section h2 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.refill-form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.refill-form input {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.refill-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* История операций */
.history-section {
    margin-top: 2rem;
}

.history-section h2 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.history-controls {
    margin-bottom: 1rem;
}

.history-table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.history-table thead {
    background: var(--dark-color);
    color: white;
}

.history-table th,
.history-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--light-color);
}

.history-table tbody tr:hover {
    background: #f8f9fa;
}

.history-table .loading,
.history-table .no-data,
.history-table .error {
    text-align: center;
    padding: 2rem;
    color: var(--gray-color);
}

.history-table .error {
    color: var(--danger-color);
}

.operation-name {
    font-weight: 500;
}

.tokens-negative {
    color: var(--danger-color);
    font-weight: bold;
}

.tokens-positive {
    color: var(--secondary-color);
    font-weight: bold;
}

.details-cell {
    font-size: 0.9rem;
    color: var(--gray-color);
}

/* Дополнительные улучшения для мобильных */

/* Улучшенное touch-взаимодействие */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-menu a,
    .upload-area {
        -webkit-tap-highlight-color: rgba(74, 144, 226, 0.3);
    }
    
    .btn {
        min-height: 44px; /* Рекомендуемый размер для touch */
    }
    
    .nav-menu a {
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Оптимизация для производительности */
.upload-icon,
.spinner,
.btn {
    will-change: transform;
}

/* Плавная прокрутка */
html {
    scroll-behavior: smooth;
}

/* Скрытие элементов при печати */
@media print {
    .navbar,
    .footer,
    .action-buttons,
    .refill-section {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .results-section,
    .tokens-section {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Темная тема для устройств (опционально) */
@media (prefers-color-scheme: dark) {
    /* Можно добавить темную тему при необходимости */
}

/* Улучшение доступности */
.btn:focus,
.form-group input:focus,
.nav-menu a:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Скрытие текста меню на маленьких экранах */
@media (max-width: 480px) {
    .nav-menu .nav-text {
        display: none;
    }
    
    .nav-menu a {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }
    
    .nav-menu a i {
        margin: 0;
    }
}

/* Анимация появления элементов */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card,
.issue-item,
.field-item {
    animation: fadeIn 0.3s ease-out;
}

/* Улучшенный индикатор загрузки */
.processing {
    animation: fadeIn 0.3s ease-out;
}

.spinner {
    box-shadow: 0 3px 10px rgba(74, 144, 226, 0.2);
}

/* Страница AI Редактора */
.editor-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
}

.editor-header {
    text-align: center;
    margin-bottom: 2rem;
}

.editor-header h1 {
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    transition: var(--transition);
    font-family: inherit;
    cursor: pointer;
}

.form-control:hover {
    border-color: #c0c0c0;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-control option {
    padding: 1rem;
    font-size: 1rem;
}

.file-upload-area {
    border: 2px dashed var(--primary-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-upload-area.drag-over {
    border-color: var(--secondary-color);
    background: rgba(80, 200, 120, 0.05);
}

.file-upload-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.file-upload-text h3 {
    color: var(--dark-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.file-upload-text p {
    color: var(--gray-color);
    margin: 0.5rem 0;
}

.btn-secondary {
    background: var(--gray-color);
    color: white;
    margin-top: 1rem;
}

.btn-secondary:hover {
    background: var(--dark-color);
}

.file-info {
    text-align: center;
}

.file-info p {
    font-size: 1.1rem;
    color: var(--dark-color);
    margin-bottom: 1rem;
}

.file-info i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.btn-remove-file {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove-file:hover {
    background: #c0392b;
}

.processing-editor {
    text-align: center;
    padding: 2rem;
    background: var(--light-color);
    border-radius: var(--border-radius);
    margin-top: 2rem;
}

.processing-editor h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

#processingStatus {
    color: var(--gray-color);
    font-size: 0.9rem;
}

.editor-result {
    margin-top: 2rem;
    animation: fadeIn 0.5s ease-out;
}

.success-card {
    border-left: 4px solid var(--secondary-color);
}

.processing-info {
    color: var(--gray-color);
    font-size: 0.95rem;
    margin: 0.5rem 0 1rem 0;
}

.processing-info i {
    color: var(--primary-color);
    margin-right: 0.3rem;
}

/* Изменения */
.changes-summary {
    background: var(--light-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.changes-summary h3 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.change-group {
    margin: 1.5rem 0;
    padding: 1rem;
    border-radius: var(--border-radius);
}

.change-group h4 {
    color: var(--dark-color);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.change-group ul {
    list-style: none;
    padding-left: 0;
}

.change-group li {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.change-group li:last-child {
    border-bottom: none;
}

.removal-group {
    background: rgba(231, 76, 60, 0.05);
    border-left: 3px solid var(--danger-color);
}

.removal-group del {
    color: var(--danger-color);
    text-decoration: line-through;
}

.replace-group {
    background: rgba(74, 144, 226, 0.05);
    border-left: 3px solid var(--primary-color);
}

.replace-group .old-text {
    color: var(--gray-color);
    font-size: 0.9rem;
    text-decoration: line-through;
}

.replace-group .new-text {
    color: var(--primary-color);
    font-weight: bold;
    background: rgba(74, 144, 226, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.replace-group i.fa-arrow-right {
    color: var(--gray-color);
    margin: 0 0.5rem;
}

.add-group {
    background: rgba(80, 200, 120, 0.05);
    border-left: 3px solid var(--secondary-color);
}

.add-group ins {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

/* Ответ AI */
.ai-response-details {
    margin-top: 1.5rem;
    border: 1px solid var(--light-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.ai-response-details summary {
    padding: 1rem;
    background: var(--light-color);
    cursor: pointer;
    font-weight: 500;
    color: var(--dark-color);
    user-select: none;
}

.ai-response-details summary:hover {
    background: #dee3e7;
}

.ai-response-details pre {
    margin: 0;
    padding: 1rem;
    background: #f8f9fa;
    color: var(--dark-color);
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Адаптивность для редактора */
@media (max-width: 768px) {
    .editor-section {
        padding: 1.5rem 1rem;
    }
    
    .file-upload-area {
        padding: 1.5rem 1rem;
        min-height: 120px;
    }
    
    .file-upload-icon {
        font-size: 2.5rem;
    }
    
    .changes-summary {
        padding: 1rem;
    }
    
    .change-group {
        padding: 0.75rem;
    }
}



