:root {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #2d3a4f;
    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 30px -8px rgba(0,0,0,0.5);
    --input-bg: #1e293b;
    --input-border: #475569;
    --tab-bg: #1e293b;
    --tab-border: #475569;
    --tab-hover: #2d3a4f;
    --tab-active: #6c9c00;
    --tab-active-text: #ffffff;
    --badge-new: #6c9c00;
    --badge-waiting: #dc2626;
    --badge-ready: #3b82f6;
    --status-new-bg: #166534;
    --status-new-text: #86efac;
    --status-waiting-bg: #991b1b;
    --status-waiting-text: #fca5a5;
    --status-ready-bg: #1e3a5f;
    --status-ready-text: #93c5fd;
    --card-waiting-bg: #3b1a1a;
    --card-waiting-border: #7f1d1d;
    --card-ready-bg: #1a2a4a;
    --card-ready-border: #1e40af;
    --modal-bg: #1e293b;
    --modal-meta-bg: #0f172a;
    --loader-border: #334155;
    --loader-top: #6c9c00;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    padding: 24px 24px 40px 24px;
    color: var(--text-primary);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

/* ===== HEADER ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header h1 {
    font-weight: 600;
    font-size: 28px;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
}

/* ===== ИКОНКА ОБНОВЛЕНИЯ (рядом с заголовком) ===== */
.icon-refresh {
    width: 24px;
    height: 24px;
    cursor: pointer;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.icon-refresh:hover {
    transform: scale(1.1);
}

.icon-refresh.rotating {
    animation: spin 0.6s ease-in-out;
}

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

/* ===== ПОИСК С ИКОНКОЙ ВНУТРИ ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 30px;
    padding: 4px 16px;
    transition: 0.2s;
    flex: 1;
    min-width: 120px;
    max-width: 320px;
}

.search-box:focus-within {
    border-color: var(--tab-active);
    box-shadow: 0 0 0 3px rgba(108, 156, 0, 0.2);
}

.search-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.5;
}

.search-box input {
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
    outline: none;
    width: 100%;
    min-width: 60px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box .clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    display: none;
}

.search-box .clear-btn.visible {
    display: block;
}

/* ===== ВКЛАДКИ ===== */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
}

.tabs::-webkit-scrollbar {
    height: 4px;
}

.tabs::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 4px;
}

.tabs::-webkit-scrollbar-thumb {
    background: var(--tab-active);
    border-radius: 4px;
}

.tab {
    padding: 10px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--tab-bg);
    border: 1px solid var(--tab-border);
    color: var(--text-muted);
    white-space: nowrap;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tab:hover {
    background: var(--tab-hover);
}

.tab.active {
    background: var(--tab-active);
    border-color: var(--tab-active);
    color: var(--tab-active-text);
    box-shadow: 0 4px 12px rgba(108, 156, 0, 0.25);
}

/* ===== СПИСОК ЗАКАЗОВ ===== */
.order-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== КАРТОЧКА ЗАКАЗА ===== */
.order-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.order-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.order-card:hover {
    border-color: var(--tab-active);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.order-card.waiting {
    background: var(--card-waiting-bg);
    border-color: var(--card-waiting-border);
}

.order-card.ready {
    background: var(--card-ready-bg);
    border-color: var(--card-ready-border);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.order-number {
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.order-status {
    display: inline-block;
    padding: 3px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.order-status.new {
    background: var(--status-new-bg);
    color: var(--status-new-text);
}

.order-status.waiting {
    background: var(--status-waiting-bg);
    color: var(--status-waiting-text);
}

.order-status.ready {
    background: var(--status-ready-bg);
    color: var(--status-ready-text);
}

.order-date {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
}

.order-row-agent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.order-agent {
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-transport {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    flex-shrink: 0;
}

.order-row-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.order-city {
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-packaging {
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    flex-shrink: 0;
}

.order-badge {
    display: none;
}

/* ===== ПАГИНАЦИЯ ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.pagination button {
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--tab-active);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 14px;
    color: var(--text-muted);
    padding: 0 12px;
}

.pagination .page-btn.active {
    background: var(--tab-active);
    border-color: var(--tab-active);
    color: white;
}

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

.empty-state .emoji {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ===== ЗАГРУЗЧИК ===== */
.loader {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 200px;
    gap: 16px;
}

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

.loader .loader-text {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}

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

/* ===== МОДАЛЬНОЕ ОКНО ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease;
}

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

.modal {
    background: var(--modal-bg);
    border-radius: 24px;
    padding: 32px 36px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 40px;
}

/* ===== МОДАЛЬНАЯ СЕТКА ===== */
.modal-info-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--modal-meta-bg);
    padding: 16px 20px;
    border-radius: 12px;
}

.modal-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    align-items: center;
}

.modal-info-left {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.modal-info-right {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-info-row.comment-row {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 4px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}

.modal-info-row.comment-row .modal-info-left {
    white-space: normal;
    word-break: break-word;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== ТАБЛИЦА ТОВАРОВ ===== */
.modal-products h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.product-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.product-table-header {
    display: grid;
    grid-template-columns: 1fr 80px 140px;
    gap: 8px;
    padding: 8px 0;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.product-table-header span:last-child {
    text-align: right;
}

.product-table-row {
    display: grid;
    grid-template-columns: 1fr 80px 140px;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    align-items: center;
}

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

.product-table-row .product-code {
    font-weight: 500;
    color: var(--text-primary);
}

.product-table-row span:last-child {
    text-align: right;
}

.product-table-row span:nth-child(2) {
    text-align: center;
}

/* ===== КНОПКА "ГОТОВ К ОТГРУЗКЕ" ===== */
.modal-footer {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

.btn-ready {
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    color: #fff;
    background: #6c9c00;
}

.btn-ready:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    body {
        padding: 16px 16px 40px 16px;
    }
    .header {
        gap: 8px;
    }
    .header h1 {
        font-size: 20px;
    }
    .header-left {
        gap: 8px;
    }
    .header-actions {
        gap: 8px;
    }
    .icon-refresh {
        width: 20px;
        height: 20px;
    }
    .search-box {
        min-width: 80px;
        padding: 2px 12px;
        flex: 0 1 140px;
    }
    .search-box input {
        font-size: 13px;
        padding: 6px 0;
        min-width: 40px;
    }
    .search-icon {
        width: 14px;
        height: 14px;
    }
    .order-card {
        padding: 14px 16px;
        gap: 6px;
    }
    .order-number {
        font-size: 17px;
        gap: 8px;
    }
    .order-status {
        font-size: 12px;
        padding: 2px 10px;
    }
    .order-date {
        font-size: 13px;
    }
    .order-row-agent {
        font-size: 15px;
    }
    .order-transport {
        font-size: 13px;
    }
    .order-row-details {
        font-size: 13px;
    }
    .tab {
        font-size: 13px;
        padding: 6px 16px;
        min-height: 36px;
    }
    .modal {
        padding: 20px;
        width: 95%;
    }
    .modal-info-row {
        gap: 2px 12px;
    }
    .modal-info-left {
        font-size: 13px;
    }
    .modal-info-right {
        font-size: 13px;
    }
    .modal-info-row.comment-row .modal-info-left {
        font-size: 12px;
    }
    .pagination button {
        font-size: 12px;
        padding: 4px 10px;
    }
    .product-table-header,
    .product-table-row {
        grid-template-columns: 1fr 60px 100px;
        gap: 4px;
        font-size: 13px;
    }
    .product-table-header span:last-child,
    .product-table-row span:last-child {
        text-align: right;
    }
    .product-table-row span:nth-child(2) {
        text-align: center;
    }
    .loader .loader-text {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px 12px 40px 12px;
    }
    .header {
        gap: 6px;
    }
    .header h1 {
        font-size: 17px;
    }
    .header-left {
        gap: 6px;
    }
    .header-actions {
        gap: 6px;
    }
    .icon-refresh {
        width: 18px;
        height: 18px;
    }
    .search-box {
        min-width: 50px;
        padding: 2px 8px;
        flex: 0 1 100px;
    }
    .search-box input {
        font-size: 12px;
        padding: 4px 0;
        min-width: 30px;
    }
    .search-icon {
        width: 12px;
        height: 12px;
    }
    .search-box .clear-btn {
        font-size: 12px;
        padding: 2px;
    }
    .order-card {
        padding: 12px 14px;
        gap: 4px;
    }
    .order-number {
        font-size: 15px;
        gap: 6px;
    }
    .order-status {
        font-size: 10px;
        padding: 1px 8px;
    }
    .order-date {
        font-size: 11px;
    }
    .order-row-agent {
        font-size: 13px;
    }
    .order-transport {
        font-size: 11px;
    }
    .order-row-details {
        font-size: 11px;
    }
    .tab {
        font-size: 12px;
        padding: 5px 12px;
        min-height: 32px;
    }
    .modal {
        padding: 16px;
    }
    .modal-info-left {
        font-size: 12px;
    }
    .modal-info-right {
        font-size: 12px;
    }
    .modal-info-row.comment-row .modal-info-left {
        font-size: 11px;
    }
    .pagination button {
        font-size: 11px;
        padding: 3px 8px;
    }
    .product-table-header,
    .product-table-row {
        grid-template-columns: 1fr 50px 80px;
        gap: 2px;
        font-size: 12px;
    }
    .product-table-header span:last-child,
    .product-table-row span:last-child {
        text-align: right;
    }
    .product-table-row span:nth-child(2) {
        text-align: center;
    }
    .loader .loader-text {
        font-size: 18px;
    }
}