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

.search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.users-page-size {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #666;
    flex-wrap: wrap;
}

.users-page-size .users-limit-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.users-page-size .users-limit-btn.active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

/* Адаптивность */

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

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

/* Страница авторизации */
.login-form {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    margin: 10vh auto;
    text-align: center;
}

.login-form h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2rem;
}

.login-form p {
    color: #666;
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.input-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

 .input-group select {
     width: 100%;
     padding: 15px;
     border: 2px solid #e1e5e9;
     border-radius: 10px;
     font-size: 16px;
     background-color: #fff;
     transition: border-color 0.3s ease;
     appearance: none;
     -webkit-appearance: none;
     -moz-appearance: none;
     background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
     background-repeat: no-repeat;
     background-position: right 14px center;
     background-size: 18px 18px;
     padding-right: 48px;
 }

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

 .input-group select:focus {
     outline: none;
     border-color: #667eea;
 }

.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 10px 20px;
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Сообщения */
.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Личный кабинет */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

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

 .balance-chip {
     display: flex;
     align-items: center;
     gap: 10px;
     padding: 6px 8px 6px 12px;
     border: 2px solid #e1e5e9;
     border-radius: 12px;
     background: #fff;
     cursor: pointer;
     transition: border-color 0.2s ease, box-shadow 0.2s ease;
 }

 .balance-chip:hover {
     border-color: #cfd6dd;
     box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
 }

 .balance-chip-label {
     font-size: 0.85rem;
     color: #666;
     font-weight: 600;
 }

 .balance-chip-amount {
     font-size: 1rem;
     font-weight: 800;
     color: #28a745;
 }

 .balance-chip-amount.negative {
     color: #dc3545;
 }

 .balance-chip-topup {
     width: 32px;
     height: 32px;
     border: none;
     border-radius: 10px;
     background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     color: #fff;
     font-weight: 800;
     font-size: 18px;
     line-height: 1;
     cursor: pointer;
     transition: transform 0.15s ease;
 }

 .balance-chip-topup:hover {
     transform: translateY(-1px);
 }

.icon-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #e1e5e9;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-button:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.icon-button svg {
    display: block;
}

.header .btn-secondary {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 20px;
}

.header h1 {
    color: #333;
    font-size: 1.8rem;
}

.dashboard-content {
    display: grid;
    gap: 30px;
}

.user-info {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.user-info h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.cvp-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 1rem;
}

.cvp-label {
    color: #666;
}

.cvp-value {
    color: #333;
    font-weight: 500;
}

.balance {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
}

.balance-label {
    color: #666;
}

.balance-amount {
    color: #28a745;
    font-weight: bold;
    font-size: 1.5rem;
}

.orders-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.orders-section h3 {
    color: #333;
    margin-bottom: 25px;
    font-size: 1.4rem;
}

.admin-subsection {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e1e5e9;
}

.orders-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.orders-list {
    display: grid;
    gap: 20px;
}

.order-card {
    border: 2px solid #f1f3f4;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.order-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.1);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.order-id {
    font-weight: bold;
    color: #333;
}

.order-date {
    color: #666;
    font-size: 0.9rem;
}

.order-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-выполнен {
    background: #d4edda;
    color: #155724;
}

.status-в-обработке {
    background: #fff3cd;
    color: #856404;
}

.status-доставляется {
    background: #cce5ff;
    color: #004085;
}

.status-ожидает-оплаты {
    background: #fff3cd;
    color: #856404;
}

.status-в-пути {
    background: #cce5ff;
    color: #004085;
}

.status-пришло {
    background: #0b5ed7;
    color: #ffffff;
}

.status-возврат {
    background: #dc3545;
    color: #ffffff;
}

.status-частично-пришло {
    background: #ffca2c;
    color: #3d2c00;
}

.status-пришло-частично {
    background: #ffca2c;
    color: #3d2c00;
}

.status-готово-к-выдаче {
    background: #198754;
    color: #ffffff;
}

.status-выдано {
    background: #0f5132;
    color: #ffffff;
}

.date-group {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.date-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f1f3f4;
}

.date-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.date-total {
    font-size: 1rem;
    font-weight: 600;
    color: #667eea;
}

.items-table {
    width: 100%;
}

.table-header {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 1fr 1fr 100px;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 10px;
}

.table-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 1fr 1fr 100px;
    gap: 10px;
    padding: 12px 10px;
    border-bottom: 1px solid #f1f3f4;
    align-items: center;
    transition: background 0.2s ease;
}

.deliveries-table .table-header,
.deliveries-table .table-row {
    grid-template-columns: 150px 0.9fr 140px 140px 1fr;
}

.table-row:hover {
    background: #f8f9fa;
}

.table-row:last-child {
    border-bottom: none;
}

.col-image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    border: 2px dashed #d0d4da;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #999;
}

.order-thumb {
    width: 75px;
    height: 75px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid #e1e5e9;
}

.image-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.image-preview-overlay.active {
    display: flex;
}

.image-preview-content img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.col-size {
    font-weight: 600;
    color: #333;
    text-align: center;
}

.col-quantity {
    color: #666;
    text-align: center;
}

.col-price {
    color: #333;
    font-weight: 500;
    text-align: right;
}

.price-expression {
    font-size: 0.8rem;
    color: #666;
}

.price-total {
    font-weight: 600;
}

.col-status {
    display: flex;
    justify-content: center;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.col-vk {
    display: flex;
    justify-content: center;
}

.vk-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #0077FF;
    color: white;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

 .vk-link svg {
     width: 30px;
     height: 30px;
     display: block;
     transform: translate(-1px, -1px);
 }

.vk-link:hover {
    background: #005DD1;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 119, 255, 0.3);
}

.loading, .no-orders {
    text-align: center;
    color: #666;
    padding: 40px;
    font-style: italic;
}

/* Модальное окно профиля */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

body.modal-locked {
    overflow: hidden;
}

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 24px 24px 20px;
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 8px !important;
    right: 12px !important;
    left: auto !important;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 28px;
    line-height: 44px;
    padding: 0;
    cursor: pointer;
    border-radius: 10px;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #333;
}

 .topup-qr {
     margin-top: 15px;
     display: flex;
     justify-content: center;
     padding: 18px;
     border: 2px dashed #e1e5e9;
     border-radius: 14px;
     background: #fbfcfd;
 }

 .topup-qr svg {
     width: 260px;
     height: 260px;
 }

 .transaction-row {
     display: flex;
     justify-content: space-between;
     align-items: center;
     gap: 12px;
     padding: 14px 16px;
     border: 1px solid #e1e5e9;
     border-radius: 12px;
     background: #fff;
     margin-bottom: 10px;
 }

 .transaction-title {
     font-weight: 700;
     color: #333;
 }

 .transaction-meta {
     margin-top: 2px;
     font-size: 0.85rem;
     color: #777;
 }

 .transaction-amount {
     font-weight: 800;
     color: #333;
     white-space: nowrap;
 }

.modal-title {
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.cvp-warning {
    margin-bottom: 15px;
    color: #666;
    font-size: 0.9rem;
}

.cvp-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cvp-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.settings-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #0077FF;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.settings-button:hover {
    background: #005DD1;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 119, 255, 0.3);
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .login-form {
        margin: 5vh auto;
        padding: 30px 20px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .date-group {
        padding: 15px;
    }
    
    .date-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .table-header {
        display: none;
    }
    
    .table-row {
        grid-template-columns: 50px 1fr;
        gap: 10px;
        padding: 10px;
        border: 1px solid #f1f3f4;
        border-radius: 8px;
        margin-bottom: 10px;
    }
    
    .col-image {
        grid-column: 1;
        grid-row: 1 / 4;
    }
    
    .col-image img {
        width: 62px;
        height: 62px;
    }
    
    .col-size {
        grid-column: 2;
        grid-row: 1;
        text-align: left;
        font-size: 0.9rem;
    }
    
    .col-size::before {
        content: "Размер: ";
        font-weight: 400;
        color: #666;
    }
    
    .col-quantity {
        grid-column: 2;
        grid-row: 2;
        text-align: left;
        font-size: 0.85rem;
    }
    
    .col-quantity::before {
        content: "Кол-во: ";
        font-weight: 600;
        color: #666;
    }
    
    .col-price {
        grid-column: 2;
        grid-row: 3;
        text-align: left;
        font-size: 0.9rem;
    }
    
    .col-price::before {
        content: "Цена: ";
        font-weight: 400;
        color: #666;
    }
    
    .col-status {
        grid-column: 1 / 3;
        grid-row: 4;
        justify-content: flex-start;
        margin-top: 5px;
    }
    
    .col-vk {
        grid-column: 1 / 3;
        grid-row: 5;
        justify-content: flex-start;
        margin-top: 5px;
    }
    
    .vk-link {
        width: 100%;
        justify-content: flex-start;
        padding: 8px 12px;
        gap: 8px;
    }
    
    .vk-link::after {
        content: "Открыть фото ВК";
        font-size: 0.85rem;
    }

    .deliveries-table .table-row {
        grid-template-columns: 1fr;
        width: 100%;
        box-sizing: border-box;
        padding: 12px;
        margin: 0 0 10px 0;
    }

    .deliveries-table {
        width: 100%;
    }

    .deliveries-table .col-date,
    .deliveries-table .col-country,
    .deliveries-table .col-cost,
    .deliveries-table .col-qty,
    .deliveries-table .col-cvp {
        grid-column: 1;
        text-align: left;
        font-size: 0.9rem;
    }

    .deliveries-table .col-date::before {
        content: "Дата: ";
        font-weight: 600;
        color: #666;
    }

    .deliveries-table .col-country::before {
        content: "Страна: ";
        font-weight: 600;
        color: #666;
    }

    .deliveries-table .col-cost::before {
        content: "Стоимость: ";
        font-weight: 600;
        color: #666;
    }

    .deliveries-table .col-qty::before {
        content: "Кол-во: ";
        font-weight: 600;
        color: #666;
    }

    .deliveries-table .col-cvp::before {
        content: "ЦВП: ";
        font-weight: 600;
        color: #666;
    }

    #deliveriesList {
        display: block;
        padding-right: 0 !important;
        padding-left: 0 !important;
    }

    .site-footer {
        background: #fff !important;
        box-sizing: border-box;
        width: auto;
        margin: 16px 10px 0;
        padding: 14px 16px;
    }

    .site-footer .footer-links {
        justify-content: center !important;
        width: 100%;
        gap: 10px;
        margin-bottom: 10px;
    }

    .site-footer .footer-info {
        align-items: center !important;
        text-align: center !important;
        font-size: 0.92rem;
        line-height: 1.35;
    }
}

.site-footer {
    max-width: 1200px;
    margin: 30px auto 0;
    padding: 20px;
    border-top: 1px solid #e9ecef;
    color: #666;
}

.site-footer .footer-links {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.site-footer .footer-links a {
    color: #007bff;
    text-decoration: none;
    font-weight: 600;
}

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

.site-footer .footer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.site-footer .footer-logo {
    width: 140px;
    height: auto;
    margin-bottom: 8px;
}

.checkbox-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: #444;
    font-size: 0.95rem;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: #007bff;
    border-radius: 6px;
}

.checkbox-group a {
    color: #007bff;
    text-decoration: none;
}

.checkbox-group a:hover {
    text-decoration: underline;
}

.btn-primary:disabled,
.btn-primary[disabled],
.btn-secondary:disabled,
.btn-secondary[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.site-footer {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-top: 1px solid #e9ecef;
    border-radius: 12px;
}

.site-footer .footer-links {
    justify-content: center;
}

.site-footer .footer-info {
    align-items: center;
    text-align: center;
}

.site-footer .footer-info {
    color: #495057;
}

.site-footer .footer-links a {
    color: #0d6efd;
}

/* ===== Админ-панель ===== */

/* Перенос кнопок в рядах действий при нехватке ширины
   (на десктопе ничего не меняет: перенос срабатывает только при переполнении) */
.modal-actions {
    flex-wrap: wrap;
    row-gap: 10px;
}

@media (max-width: 768px) {
    /* Таблицы админки с фиксированными колонками скроллим по горизонтали.
       Шапка и строки лежат в одном контейнере, поэтому скроллятся вместе —
       таблица перестаёт выезжать за пределы экрана. */
    body.admin-page .items-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.admin-page .items-table .table-header,
    body.admin-page .items-table .table-row {
        min-width: max-content;
    }

    /* Шапка: имя админа и кнопки переносятся и центрируются */
    body.admin-page .header-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Блоки управления (дата, файл, ID и т.п.): каждое поле — на всю ширину,
       кнопки остаются в общем потоке и переносятся сами */
    body.admin-page .modal-actions > .input-group {
        flex: 1 1 100%;
        max-width: 100% !important;
    }

    /* Кнопки управления растягиваются на свободную ширину */
    body.admin-page .modal-actions > .btn-secondary,
    body.admin-page .modal-actions > .btn-primary {
        flex: 1 1 auto;
    }
}
