.coach-layout {
    --seat-w: clamp(22px, calc((100vw - 64px) / 14), 42px);
    --seat-h: clamp(18px, calc(var(--seat-w) * 0.78), 30px);
    --seat-gap: clamp(3px, calc(var(--seat-w) * 0.16), 6px);
    --row-gap: clamp(3px, calc(var(--seat-w) * 0.18), 8px);

    max-width: min(100%, 900px);
    margin: 24px auto;
    padding: clamp(10px, 2vw, 18px);
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

.coach-layout__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.coach-layout__title {
    margin: 0;
    font-size: 20px;
    color: #1d2433;
}

.coach-layout__meta {
    margin: 0 0 8px;
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 12px;
    color: #4e5b78;
}

.coach-layout__key-item {
    display: inline-flex;
    align-items: center;
	font-size: 16px;
    gap: 6px;
    white-space: nowrap;
}

.coach-layout__key-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.coach-layout__key-dot--available {
    background: #0f5a0d;
}

.coach-layout__key-dot--unavailable {
    background: #6b7280;
}

.coach-layout__side-label {
    margin: 10px 0;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #1d2433;
}

.coach-layout__side-label--top {
    margin-top: 12px;
}

.coach-layout__side-label--bottom {
    margin-top: 12px;
    margin-bottom: 0;
}

.coach-layout__grid {
    display: flex;
    flex-direction: row;
    gap: var(--row-gap);
    overflow-x: hidden;
    padding-bottom: 4px;
    padding-top: 4px;
}

.coach-layout__row {
    display: grid;
    grid-template-columns: var(--seat-w);
    grid-template-rows: repeat(5, var(--seat-h));
    gap: var(--seat-gap);
    column-gap: var(--seat-gap);
    row-gap: var(--seat-gap);
    align-items: center;
    width: max-content;
    flex: 0 0 auto;
}

.coach-cell {
    width: 100%;
    min-height: var(--seat-h);
    height: var(--seat-h);
    box-sizing: border-box;
    border-radius: clamp(4px, 0.6vw, 7px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(10px, 1.3vw, 14px);
    font-weight: 700;
    user-select: none;
}

.coach-cell--seat {
    border: 1px solid #cad3e6;
}

.coach-cell--available {
    background: #e8f7e7;
    color: #0f5a0d;
}

.coach-cell--reserved {
    background: #e5e7eb;
    color: #374151;
}

.coach-cell--conflict {
    outline: 2px solid #de7b00;
    outline-offset: -2px;
}

.coach-cell--fixed {
    background: #e8eefb;
    color: #34466f;
    border: 1px solid #c8d5f1;
}

.coach-cell--driver,
.coach-cell--toilet {
    font-size: 9px;
    letter-spacing: 0.02em;
}

.coach-cell--aisle,
.coach-cell--empty {
    background: transparent;
    border: none;
}

@media (max-width: 1024px), (min-width: 1025px) and (max-width: 1366px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
    .coach-layout {
        margin: 12px auto;
        padding: 8px;
        --seat-w: clamp(30px, 8.5vw, 40px);
        --seat-h: clamp(25px, calc(var(--seat-w) * 0.78), 33px);
        --seat-gap: clamp(5px, calc(var(--seat-w) * 0.2), 8px);
        --row-gap: clamp(6px, calc(var(--seat-w) * 0.24), 10px);
    }

    .coach-layout__grid {
        flex-direction: column;
        align-items: center;
        overflow: visible;
    }

    .coach-layout__side-label {
        display: none;
    }

    .coach-layout__row {
        grid-template-columns: repeat(5, var(--seat-w));
        grid-template-rows: var(--seat-h);
        gap: clamp(6px, 2vw, 10px);
        column-gap: clamp(6px, 2vw, 10px);
        row-gap: clamp(6px, 2vw, 10px);
        direction: rtl;
    }

    .coach-cell {
        font-size: clamp(13px, 4.2vw, 17px);
    }

    .coach-cell--driver {
        font-size: 0;
    }

    .coach-cell--driver::before {
        content: "D";
        font-size: clamp(13px, 4.2vw, 17px);
        line-height: 1;
    }
}

@media (max-width: 480px) {
    .coach-layout__meta {
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }
}
