:root {
    --spacing: 1rem;
    --sidebar-width: 250px;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--card-background-color);
    border-right: 1px solid var(--muted-border-color);
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar nav h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--muted-color);
}

.sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar nav li {
    margin-bottom: 0.5rem;
}

.sidebar nav a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--color);
    border-radius: var(--border-radius);
    transition: background-color 0.2s;
}

.sidebar nav a:hover {
    background: var(--card-sectionning-background-color);
}

.sidebar nav a.active {
    background: var(--primary);
    color: var(--primary-inverse);
}

.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
}

.section-content {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#lots-platform-filter {
    min-width: 220px;
}

#stats {
    font-size: 0.9rem;
    color: var(--muted-color);
}

#lots-stats {
    font-size: 0.9rem;
    color: var(--muted-color);
}

.transportation-card {
    border: 1px solid var(--muted-border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    background: var(--card-background-color);
}

.lot-card {
    border-left: 4px solid var(--primary);
}

.transportation-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--muted-border-color);
}

.transportation-number {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary);
}

.transportation-id {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.transportation-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.meta-item {
    color: var(--muted-color);
}

.route-section {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.route-point {
    padding: 1rem;
    background: var(--card-sectionning-background-color);
    border-radius: var(--border-radius);
}

.route-arrow {
    font-size: 2rem;
    color: var(--primary);
}

.route-city {
    font-weight: bold;
    font-size: 1.1rem;
}

.route-region {
    font-size: 0.9rem;
    color: var(--muted-color);
}

.route-region-calculated {
    font-size: 0.85rem;
    color: var(--primary);
    font-style: italic;
    margin-top: 0.25rem;
}

.route-date {
    font-size: 0.85rem;
    color: var(--muted-color);
    margin-top: 0.5rem;
}

.cargo-section {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
}

.cargo-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cargo-label {
    font-weight: bold;
    color: var(--muted-color);
}

.cargo-value {
    font-size: 1.1rem;
}

/* Pricing section */
.pricing-section {
    background: var(--card-sectionning-background-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.pricing-title {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.price-group {
    padding: 0.75rem;
    background: var(--card-background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--muted-border-color);
}

.price-group-title {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--muted-color);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    padding: 0.25rem 0;
}

.price-item span:first-child {
    color: var(--muted-color);
}

.price-item strong {
    color: var(--primary);
}

.carrier-section {
    background: var(--card-sectionning-background-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.carrier-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.carrier-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    font-size: 0.9rem;
}

.carrier-detail {
    display: flex;
    gap: 0.5rem;
}

.carrier-detail-label {
    color: var(--muted-color);
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.actions button {
    margin: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    margin: 0;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--muted-color);
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--muted-border-color);
    }
    
    .content {
        margin-left: 0;
    }
    
    .route-section {
        grid-template-columns: 1fr;
    }
    
    .route-arrow {
        text-align: center;
        transform: rotate(90deg);
    }
    
    .cargo-section {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Стили для сопоставлений */
#matches-stats {
    font-size: 0.85rem;
    color: var(--muted-color);
}

#matches-last-update {
    font-size: 0.85rem;
    color: var(--muted-color);
    font-style: italic;
}

.match-group-card {
    border: 1px solid var(--primary);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: var(--card-background-color);
}

.transportation-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--muted-border-color);
}

.transportation-section h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: var(--primary);
}

.transportation-section .route-section {
    margin-bottom: 0.75rem;
}

.transportation-section .route-point {
    padding: 0.5rem;
    font-size: 0.85rem;
}

.transportation-section .route-city {
    font-size: 0.9rem;
}

.transportation-section .route-region {
    font-size: 0.8rem;
}

.transportation-section .route-date {
    font-size: 0.75rem;
}

.transportation-section .cargo-section {
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.transportation-section .cargo-item {
    font-size: 0.85rem;
}

.transportation-section .carrier-section {
    padding: 0.75rem;
    font-size: 0.85rem;
}

.transportation-section .carrier-name {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.transportation-section .carrier-details {
    font-size: 0.8rem;
    gap: 0.5rem;
}

.lots-section h4 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    color: var(--secondary);
}

.lots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1rem;
}

.lot-match-card {
    border: 1px solid var(--muted-border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    background: var(--card-sectionning-background-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.lot-match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.lot-match-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--muted-border-color);
    flex-shrink: 0;
}

.lot-match-id {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--secondary);
    word-break: break-all;
}

.lot-match-price {
    font-weight: bold;
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: var(--card-background-color);
    border-radius: var(--border-radius);
    text-align: center;
}

.lot-match-card .route-section {
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.lot-match-card .route-point {
    padding: 0.75rem;
    font-size: 0.75rem;
}

.lot-match-card .route-city {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lot-match-card .route-region {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lot-match-card .route-date {
    font-size: 0.7rem;
    margin-top: 0.25rem;
}

.lot-match-card .route-arrow {
    font-size: 1.2rem;
}

.lot-match-card .cargo-section {
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
}

.lot-match-card .cargo-item {
    gap: 0.25rem;
}

.lot-match-card .cargo-label {
    font-size: 0.75rem;
}

.lot-match-card .cargo-value {
    font-size: 0.8rem;
}

.lot-match-actions {
    margin-top: auto;
    padding-top: 0.75rem;
}

.lot-match-actions button {
    width: 100%;
    margin: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .lots-grid {
        grid-template-columns: 1fr;
    }
}

/* Подбор и диагностика лотов */
.lot-tabs, .lot-statistics { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.lot-tabs button, .lot-statistics button { width: auto; margin: 0; }
.lot-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: .8rem; align-items: end; }
.lot-filters input, .lot-filters select { margin-bottom: 0; }
.filter-help, .result-metadata, .snapshot-metadata { font-size: .85rem; color: #54616e; }
.snapshot-metadata { overflow-wrap: anywhere; }
.source-state { margin-bottom: .4rem; }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: .3rem; background: #eaf1f7; color: #23445d; margin: .3rem .4rem .3rem 0; font-size: .85rem; }
.badge-warning { background: #fff0c2; color: #735100; }
.error { color: #ae2424; }
.lot-reasons { margin: .7rem 0; padding-left: 1.3rem; }
.result-metadata { margin-top: 1rem; overflow-wrap: anywhere; }
.original-data { margin-top: .8rem; }
.original-data pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 22rem; overflow: auto; }
.lot-match-id small { display: block; font-weight: normal; overflow-wrap: anywhere; }
.stats-bar { height: 20px; background: #e0e0e0; border-radius: 4px; overflow: hidden; }
.stats-bar > div { height: 100%; background: #4caf50; }
.platform-stat { margin: 0; width: auto; }
@media (max-width: 1000px) { .lot-filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .lot-filters { grid-template-columns: 1fr; } }
