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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.search-form {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.login-form {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.form-group {
    margin-bottom: 15px;
}

/* Стили для фильтров заказов */
.orders-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.filter-group select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 180px;
}

.filter-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Стили для баланса клиента в навигации */
.client-balance {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    margin-left: auto;
}

.client-balance .balance-label,
.client-balance .debt-label {
    color: #666;
    font-weight: 500;
}

.client-balance #balance-label {
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.client-balance #balance-label:hover {
    color: #fff;
    background: linear-gradient(135deg, #0056b3 0%, #004080 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.client-balance #balance-label::before {
    content: "📊";
    font-size: 14px;
}

.client-balance .balance-value {
    color: #28a745;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.client-balance .balance-value:hover {
    color: #1e7e34;
    text-decoration-style: solid;
}

.client-balance .debt-value {
    color: #dc3545;
    font-weight: bold;
    font-size: 16px;
}

.client-balance .btn-history {
    padding: 4px 10px;
    font-size: 12px;
    background: #6c757d;
    border-radius: 4px;
}

.client-balance .btn-history:hover {
    background: #5a6268;
}

/* Стили для модального окна истории баланса */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

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

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Стили для истории баланса */
.balance-history-filters {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    display: flex;
    gap: 15px;
}

.balance-history-filters .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.balance-history-filters label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.balance-history-filters select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.balance-history-filters select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.balance-history-content {
    max-height: 500px;
    overflow-y: auto;
}

.balance-history-transactions {
    margin-top: 15px;
}

.balance-transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.balance-transaction-item:hover {
    background-color: #f8f9fa;
}

.balance-transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    flex: 1;
}

.transaction-description {
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
}

.transaction-type {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    font-weight: 500;
}

.transaction-type.deposit {
    color: #28a745;
}

.transaction-type.refund {
    color: #dc3545;
}

.transaction-type.order {
    color: #007bff;
}

.transaction-amount {
    font-size: 16px;
    font-weight: bold;
    margin-right: 20px;
}

.transaction-amount.positive {
    color: #28a745;
}

.transaction-amount.negative {
    color: #dc3545;
}

.transaction-date {
    font-size: 12px;
    color: #999;
    min-width: 150px;
    text-align: right;
}

.balance-history-empty {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

button {
    background: #007bff;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
}

button:hover {
    background: #0056b3;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}

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

.btn-secondary {
    background: #6c757d;
    padding: 8px 16px;
    width: auto;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-small {
    background: #6c757d;
    color: white;
    padding: 4px 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    text-decoration: none;
}

.btn-small:hover {
    background: #5a6268;
}

.loading {
    text-align: center;
    padding: 20px;
    display: none;
}

.loading.active {
    display: block;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.error.active {
    display: block;
}

.success {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.success.active {
    display: block;
}

.results {
    margin-top: 20px;
}

.result-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.result-card h3 {
    color: #333;
    margin-bottom: 4px;
    font-size: 14px;
}

.result-card h3 a.article-link {
    color: #007bff;
    text-decoration: none;
    cursor: pointer;
}

.result-card h3 a.article-link:hover {
    text-decoration: underline;
    color: #0056b3;
}

.product-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 5px;
    margin-bottom: 8px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.info-value {
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

.price-info {
    background: #e8f4fd;
    padding: 6px;
    border-radius: 4px;
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-with-markup {
    color: #28a745;
    font-size: 16px;
    font-weight: bold;
}

.analog-label {
    color: #ff0000;
    font-weight: bold;
    margin-top: 5px;
}

.order-section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.quantity-input {
    width: 80px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

.btn-order {
    background: #28a745;
    color: white;
    padding: 10px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    width: auto;
}

.btn-order:hover {
    background: #218838;
}

.btn-order:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.order-success {
    background: #d4edda;
    color: #155724;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 10px;
}

.order-error {
    background: #f8d7da;
    color: #721c24;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 10px;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
}

.show-more-container {
    text-align: center;
    margin-top: 20px;
}

.btn-show-more {
    background: #007bff;
    color: white;
    padding: 12px 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: auto;
}

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

.hidden-results {
    display: none;
}

.header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 30px;
}

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

.user-info {
    color: #28a745;
    font-weight: bold;
    margin-right: 10px;
}

.finance-info {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-right: 10px;
}

.finance-item {
    background: #e8f4fd;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.finance-label {
    color: #666;
    font-size: 12px;
    margin-right: 5px;
}

.finance-value {
    font-weight: bold;
    color: #333;
}

.finance-value.balance {
    color: #28a745;
}

.finance-value.debt {
    color: #dc3545;
}

.hidden {
    display: none;
}

/* Стили для навигации */
.nav-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
}

.nav-tab {
    padding: 10px 20px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 14px;
    color: #666;
}

.nav-tab:hover {
    background: #e9ecef;
}

.nav-tab.active {
    background: white;
    color: #333;
    font-weight: bold;
    border-bottom: 2px solid white;
    margin-bottom: -2px;
}

.nav-tab .badge {
    background: #007bff;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    margin-left: 5px;
}

/* Стили для скрытия элементов */
.hidden {
    display: none !important;
}

/* Стили для разделов */
.section {
    display: block;
}

.section.active {
    display: block;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    display: inline-block;
}

/* Кликабельный статус "Выдано" для перевода в "Отказ" */
.clickable-status {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.clickable-status:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.clickable-status::after {
    content: ' ✕';
    font-size: 10px;
    opacity: 0.7;
}

.status-pending {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #ddd;
}

.status-in_delivery {
    background-color: #9b59b6;
    color: white;
}

.status-delivered {
    background-color: #27ae60;
    color: white;
}

.status-cancelled {
    background-color: #e74c3c;
    color: white;
}

.status-ready_for_pickup {
    background-color: #27ae60;
    color: white;
}

/* Стили для таблицы заказов */
.orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.orders-table th,
.orders-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

.orders-table th {
    background: #f5f5f5;
    font-weight: bold;
}

.orders-table tr:nth-child(even) {
    background: #f9f9f9;
}

/* Стили для корзины */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    background: #fff;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.cart-item-details {
    color: #666;
    font-size: 14px;
}

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

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cart-item-quantity input {
    width: 60px;
    padding: 5px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.btn-remove {
    background: #dc3545;
    color: white;
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

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

.cart-summary {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-total {
    font-size: 18px;
    font-weight: bold;
}

.btn-checkout {
    background: #28a745;
    color: white;
    padding: 12px 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: auto;
}

.btn-checkout:hover {
    background: #218838;
}

.btn-checkout:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.empty-cart,
.empty-orders {
    text-align: center;
    padding: 40px;
    color: #666;
}

.btn-add-to-cart {
    background: #17a2b8;
    color: white;
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    width: auto;
}

.btn-add-to-cart:hover {
    background: #138496;
}

/* Кнопка возврата наверх */
.scroll-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s;
}

.scroll-to-top:hover {
    background: #0056b3;
}

.scroll-to-top.show {
    display: block;
}

/* Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 14px;
    }

    .container {
        padding: 15px;
        max-width: 100%;
    }

    h1 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .header {
        flex-direction: column;
        gap: 10px;
    }

    .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .header-actions .btn:first-child {
        margin-left: 0;
    }

    #logout-btn {
        margin-left: auto;
        padding: 5px 10px !important;
        font-size: 12px !important;
    }

    .search-form {
        padding: 15px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    input[type="text"],
    input[type="password"] {
        padding: 8px;
        font-size: 16px; /* Увеличиваем для мобильных */
    }

    button,
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .result-card {
        padding: 8px;
        margin-bottom: 8px;
    }

    .result-card h3 {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .product-info {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .info-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .info-label {
        font-weight: bold;
        margin-right: 8px;
    }

    .price-info {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-top: 8px;
    }

    .price-with-markup {
        font-size: 16px;
        font-weight: bold;
    }

    .order-section {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .quantity-input {
        width: 60px;
        padding: 6px;
        font-size: 14px;
    }

    .btn-order {
        flex: 1;
        padding: 8px 12px;
        font-size: 13px;
    }

    .nav-tabs {
        flex-wrap: wrap;
        gap: 5px;
    }

    .nav-tabs button {
        flex: 1;
        min-width: 100px;
        padding: 8px 12px;
        font-size: 13px;
    }

    .orders-table {
        font-size: 12px;
        width: 100%;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .orders-table thead,
    .orders-table tbody,
    .orders-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    .orders-table th,
    .orders-table td {
        padding: 6px 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .status-badge {
        padding: 2px 6px;
        font-size: 10px;
    }

    .scroll-to-top {
        width: 40px;
        height: 40px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    #logout-btn {
        padding: 5px 10px !important;
        font-size: 12px !important;
    }
}

/* Стили для планшетов */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95%;
        padding: 15px;
    }

    .result-card {
        padding: 6px;
    }

    .product-info {
        grid-template-columns: repeat(2, 1fr);
    }
}
