/* MAXWELL responsive layout — loaded last on every authenticated page. */

html {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

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

.topbar {
    width: 100%;
    max-width: 100%;
    min-height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "brand spacer profile"
        "nav nav nav";
    align-items: center;
    gap: 10px 20px;
    padding: 12px max(20px, calc((100% - 1180px) / 2));
}

.topbar .brand {
    grid-area: brand;
    min-width: 0 !important;
}

.topbar .main-nav {
    grid-area: nav;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin: 0;
    overflow: visible;
    align-items: center;
}

.topbar .main-nav a {
    flex: 0 0 auto;
    min-height: 44px !important;
    height: 44px !important;
    padding: 9px 12px !important;
    white-space: nowrap;
}

.topbar .profile {
    grid-area: profile;
    min-width: 0;
    margin-left: auto;
}

.topbar .profile form {
    flex: 0 0 auto;
    margin: 0;
}

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

.mobile-nav-account {
    display: none;
}

.container {
    width: min(1180px, calc(100% - 40px));
    max-width: 1180px;
    min-width: 0;
    margin-inline: auto;
}

.container > *,
.panel,
.card,
.mx-card,
.mx-task,
.mx-contract,
.form-stack,
.section-heading,
.history-filter,
.employee-card,
.employee-info,
.employee-main {
    min-width: 0;
    max-width: 100%;
}

.panel,
.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.table-wrap table,
.panel table {
    box-shadow: none;
}

input,
select,
textarea,
button,
.button,
.btn,
.outline-button {
    max-width: 100%;
}

.birthday-banner {
    width: min(1180px, calc(100% - 40px));
}

@media (min-width: 1181px) {
    .topbar {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }
}

@media (max-width: 1100px) {
    .topbar {
        padding-inline: 20px;
    }

    .topbar .brand-word {
        font-size: 23px;
    }

    .topbar .profile > span {
        max-width: 100px;
    }

    .cards,
    .mx-grid,
    .dashboard-grid,
    .summary-grid,
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 820px) {
    .topbar {
        position: relative;
        z-index: 1000;
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas: "brand menu profile";
        gap: 8px;
        padding: 10px 14px;
    }

    .topbar .brand {
        max-width: 190px;
        justify-content: flex-start !important;
        gap: 8px !important;
    }

    .topbar .brand-word {
        font-size: 20px;
    }

    .topbar .brand-tagline {
        display: none;
    }

    .topbar .brand-logo {
        width: 38px !important;
        height: 38px !important;
        flex: 0 0 38px !important;
    }

    .mobile-menu-toggle {
        grid-area: menu;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 42px;
        padding: 8px 11px;
        border: 1px solid rgba(255, 255, 255, .18);
        border-radius: 10px;
        background: rgba(255, 255, 255, .09);
        color: #fff;
        font-size: 12px;
        line-height: 1;
        box-shadow: none;
    }

    .mobile-menu-toggle:hover,
    .mobile-menu-toggle:focus-visible {
        background: rgba(255, 255, 255, .16);
        transform: none;
    }

    .mobile-menu-icon {
        width: 16px;
        font-size: 18px;
        line-height: 1;
    }

    .topbar .main-nav {
        position: absolute;
        top: calc(100% + 1px);
        left: 12px;
        right: 12px;
        width: auto;
        display: none !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        max-height: calc(100vh - 88px);
        padding: 10px;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        border: 1px solid rgba(255, 255, 255, .14);
        border-radius: 0 0 16px 16px;
        background: #091c32;
        box-shadow: 0 18px 38px rgba(3, 14, 29, .30);
    }

    .topbar.nav-open .main-nav {
        display: grid !important;
    }

    .topbar .main-nav a {
        display: flex;
        align-items: center;
        min-height: 44px;
        height: auto !important;
        padding: 10px 12px;
        white-space: normal;
    }

    .topbar .main-nav a.active::after {
        left: 12px;
        right: 12px;
    }

    .mobile-nav-account {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, .12);
    }

    .mobile-nav-user {
        grid-column: 1 / -1;
        padding: 4px 12px;
        overflow: hidden;
        color: #aebfd2;
        font-size: 12px;
        font-weight: 700;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-nav-account form {
        min-width: 0;
        margin: 0;
    }

    .mobile-logout-button {
        width: 100%;
        min-height: 44px;
        border: 1px solid rgba(255, 255, 255, .14);
        background: rgba(255, 255, 255, .07);
        color: #fff;
        text-align: left;
        box-shadow: none;
    }

    .topbar .profile {
        gap: 5px;
    }

    .topbar .profile > span,
    .topbar .profile form,
    .topbar .account-password-button {
        display: none;
    }

    .topbar .chat-button,
    .topbar .notification-button,
    .topbar .settings-button {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px;
        margin: 0;
        padding: 0 !important;
    }

    .notification-panel {
        position: fixed !important;
        top: 68px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 84px);
    }

    .container {
        width: calc(100% - 24px);
        padding: 22px 0 44px;
    }

    .birthday-banner {
        width: calc(100% - 24px);
        margin: 10px auto 0;
    }

    .hero,
    .section-heading,
    .history-filter,
    .mx-dashboard-head,
    .mx-section-head,
    .employee-page-header,
    .employee-heading {
        align-items: stretch !important;
        flex-direction: column !important;
        gap: 14px !important;
    }

    .section-heading > *,
    .history-filter > *,
    .history-filter form,
    .employee-heading-actions {
        width: 100%;
        min-width: 0 !important;
    }

    .panel {
        padding: 18px;
        border-radius: 14px;
    }

    .cards,
    .mx-grid,
    .dashboard-grid,
    .summary-grid,
    .stats-grid,
    .employee-grid,
    .employees-grid,
    .warehouse-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .employee-grid {
        gap: 14px !important;
    }

    .employee-card {
        padding: 14px !important;
        gap: 12px !important;
    }

    .employee-photo-link,
    .employee-photo-link .employee-photo {
        width: 76px !important;
        height: 94px !important;
        flex-basis: 76px !important;
    }

    .employee-name-link h2 {
        font-size: 16px !important;
    }

    form[style*="display:flex"],
    form[style*="display: flex"],
    div[style*="display:flex"],
    div[style*="display: flex"] {
        flex-wrap: wrap;
    }

    h1 {
        font-size: clamp(25px, 8vw, 32px);
    }

    h2 {
        overflow-wrap: anywhere;
    }
}

@media (max-width: 520px) {
    .topbar {
        grid-template-columns: minmax(0, 1fr) auto auto;
        padding-inline: 10px;
    }

    .topbar .brand {
        gap: 8px;
    }

    .topbar .brand-word {
        font-size: 17px;
        letter-spacing: .04em;
    }

    .topbar .brand-logo {
        width: 34px !important;
        height: 34px !important;
        flex-basis: 34px !important;
    }

    .mobile-menu-toggle {
        min-height: 38px;
        padding-inline: 9px;
    }

    .mobile-menu-toggle > span:last-child {
        display: none;
    }

    .topbar .profile .chat-button {
        display: none;
    }

    .topbar .profile .notification-button,
    .topbar .profile .settings-button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px;
    }

    .topbar .main-nav {
        left: 8px;
        right: 8px;
        grid-template-columns: minmax(0, 1fr);
    }

    .mobile-nav-account {
        grid-template-columns: minmax(0, 1fr);
    }

    .container {
        width: calc(100% - 20px);
        padding-top: 18px;
    }

    .panel,
    .card,
    .mx-card,
    .mx-task,
    .mx-contract {
        border-radius: 12px !important;
    }

    .panel {
        padding: 14px;
    }

    .card,
    .mx-card,
    .mx-task,
    .mx-contract {
        padding: 15px;
    }

    button,
    .button,
    .btn,
    .outline-button {
        min-height: 42px;
    }

    .employee-card {
        display: grid !important;
        grid-template-columns: 68px minmax(0, 1fr);
    }

    .employee-photo-link,
    .employee-photo-link .employee-photo {
        width: 68px !important;
        height: 84px !important;
        flex-basis: 68px !important;
    }

    th,
    td {
        padding: 11px 9px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
