* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

a,
button,
input,
select,
textarea {
    max-width: 100%;
}

.main-content,
.main-header-container {
    min-width: 0;
}

.mobile-menu-toggle {
    display: none;
}

.main-content {
    overflow-wrap: anywhere;
}

.main-content table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
}

.shipment-checks {
    display: contents;
}

.auth-layout > .max-w-6xl {
    width: 100%;
    max-width: 72rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.auth-layout a {
    overflow-wrap: anywhere;
}

.login-page {
    min-height: 100vh;
    margin: 0;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.login-page .login-box {
    width: min(100%, 360px);
    margin: clamp(24px, 12vh, 100px) auto 24px;
}

@media (max-width: 1023px) {
    .main-header-container {
        position: relative;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .main-header-inner {
        height: auto !important;
        min-height: 3.75rem;
        padding: 0.25rem 0;
        flex-direction: row;
        align-items: center;
        gap: 0.75rem !important;
    }

    .main-brand-nav {
        position: static;
        flex: 1;
        min-width: 0;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem !important;
    }

    .main-brand-nav img {
        width: 6rem;
        height: 3rem;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        width: 2.75rem;
        height: 2.75rem;
        flex: 0 0 2.75rem;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.3rem;
        padding: 0;
        border: 1px solid #475569;
        border-radius: 0.65rem;
        background: #1e293b;
        cursor: pointer;
    }

    .mobile-menu-toggle span {
        display: block;
        width: 1.2rem;
        height: 2px;
        border-radius: 2px;
        background: #fff;
        transition: transform 160ms ease, opacity 160ms ease;
    }

    .mobile-menu-toggle.is-open span:first-child {
        transform: translateY(0.42rem) rotate(45deg);
    }

    .mobile-menu-toggle.is-open span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.is-open span:last-child {
        transform: translateY(-0.42rem) rotate(-45deg);
    }

    .main-nav {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        z-index: 50;
        display: none !important;
        width: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0.2rem !important;
        padding: 0.5rem;
        border: 1px solid #334155;
        border-radius: 0 0 0.8rem 0.8rem;
        background: #0f172a;
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
    }

    .main-nav.is-open {
        display: flex !important;
    }

    .main-nav a {
        width: 100%;
        padding: 0.7rem 0.75rem !important;
        line-height: 1.3;
    }

    .main-user-actions {
        justify-content: flex-end;
        gap: 0.5rem !important;
        margin: 0;
        padding: 0;
        border: 0;
    }

    .main-user-actions > div {
        display: none;
    }

    .main-user-actions > a {
        padding: 0.6rem 0.75rem !important;
        white-space: nowrap;
    }
}

@media (max-width: 767px) {
    .main-content {
        padding: 1.25rem 1rem !important;
    }

    .main-content h1 {
        font-size: clamp(1.45rem, 7vw, 1.9rem);
        line-height: 1.2;
    }

    .main-content .flex.justify-between,
    .main-content .flex.items-end {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .main-content [class*="min-w-[300px]"] {
        width: 100%;
        min-width: 0;
    }

    .main-content input[type="file"] {
        font-size: 0.9rem;
    }

    .main-content table {
        display: block;
        width: 100% !important;
        border: 0 !important;
    }

    .main-content table thead {
        position: absolute !important;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .main-content table tbody {
        display: block;
        width: 100%;
    }

    .main-content table tbody tr {
        display: block;
        width: 100%;
        margin: 0 0 0.75rem;
        padding: 0.45rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.75rem;
        background: #fff;
    }

    .main-content table tbody td {
        display: grid;
        grid-template-columns: minmax(5.25rem, 36%) minmax(0, 1fr);
        align-items: start;
        gap: 0.5rem;
        min-width: 0;
        padding: 0.45rem !important;
        border: 0 !important;
        text-align: left !important;
        overflow-wrap: anywhere;
    }

    .main-content table tbody td::before {
        content: attr(data-mobile-label);
        color: #64748b;
        font-size: 0.64rem;
        font-weight: 700;
        line-height: 1.35;
        text-transform: uppercase;
        overflow-wrap: anywhere;
    }

    .main-content table tbody td:not([data-mobile-label])::before,
    .main-content table tbody td[data-mobile-label=""]::before {
        display: none;
    }

    .main-content table tbody td[colspan] {
        display: block;
    }

    .main-content table tbody td[colspan]::before {
        display: none;
    }

    .main-content table tbody td[data-mobile-label="Проверки"] {
        grid-template-columns: minmax(0, 1fr);
    }

    .main-content table tbody td[data-mobile-label="Проверки"]::before {
        margin-bottom: 0.15rem;
    }

    .shipment-checks {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.35rem;
    }

    .shipment-checks > span {
        display: flex;
        min-width: 0;
        min-height: 2rem;
        align-items: center;
        justify-content: center;
        margin: 0 !important;
        padding: 0.35rem 0.2rem;
        border: 1px solid transparent;
        border-radius: 0.45rem;
        font-size: 0.7rem;
        line-height: 1;
    }

    .shipment-checks .text-green-600 {
        border-color: #a7f3d0;
        background: #ecfdf5;
        color: #047857;
    }

    .shipment-checks .text-red-600 {
        border-color: #fecaca;
        background: #fef2f2;
        color: #b91c1c;
    }

    .auth-layout > .max-w-6xl {
        padding: 1rem;
    }

    .auth-layout {
        display: block !important;
    }

    .auth-layout .flex.justify-between {
        flex-wrap: wrap;
    }

    .auth-layout .text-right {
        text-align: left;
    }

    .main-content #documentUploadModal > div {
        max-height: calc(100dvh - 2rem);
        overflow-y: auto;
    }

    .login-page .error {
        overflow-wrap: anywhere;
    }
}
