/* Ajustes mobile-first. El layout de escritorio se restablece desde md. */
body {
    overflow-x: hidden;
}

.login-page {
    padding: 16px;
}

.login-card {
    padding: 28px 20px;
}

.login-card .form-control,
.login-card .btn-login {
    min-height: 48px;
    font-size: 16px;
}

.login-logo {
    margin-bottom: 24px;
}

.mobile-menu-grid .btn {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
}

.sale-form {
    padding-bottom: 72px;
}

.sale-form > .row > [class*="col-"] {
    margin-bottom: 16px;
}

.sale-form .form-control,
.sale-form .form-select {
    min-height: 48px;
    font-size: 16px;
}

.sale-form .btn-group > .btn {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-native-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.mobile-choice-grid {
    display: grid;
    gap: 8px;
}

.mobile-choice-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-choice-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-choice-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mobile-choice {
    min-width: 0;
    min-height: 52px;
    padding: 8px 5px;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-weight: 600;
    line-height: 1.15;
}

.mobile-choice strong,
.mobile-choice span {
    display: block;
}

.mobile-choice span {
    margin-top: 2px;
    font-size: 0.72rem;
    font-weight: 500;
}

.mobile-choice.active {
    border-color: #0d6efd;
    background: #0d6efd;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.sale-form .form-switch {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 0;
}

.sale-form .form-switch .form-check-input {
    width: 46px;
    height: 26px;
    margin: 0;
    flex: 0 0 46px;
}

.sale-submit {
    position: fixed;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    z-index: 1030;
    width: calc(100% - 24px);
    min-height: 54px;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.25);
}

.main-content .form-control,
.main-content .form-select {
    min-height: 44px;
    font-size: 16px;
}

.main-content .btn:not(.sale-submit) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.main-content .card-body {
    padding: 16px;
}

.main-content .container {
    padding-right: 0;
    padding-left: 0;
}

.table-responsive {
    width: 100%;
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}

.table-responsive th {
    white-space: nowrap;
}

.mobile-action-group {
    flex-direction: column;
}

.mobile-action-group .btn {
    width: 100%;
}

.mobile-turn-item {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 4px;
}

.topbar {
    padding: 0 12px;
}

.topbar .brand {
    min-width: 0;
    font-size: 1rem;
    white-space: nowrap;
}

.topbar .right {
    gap: 8px;
}

.topbar .role-badge,
.topbar-user {
    display: none;
}

.topbar-logout {
    min-height: 44px;
    padding: 0 8px;
}

.topbar-logout i {
    font-size: 1rem;
}

.topbar-logout {
    font-size: 0;
}

.mobile-menu-button {
    width: 44px;
    height: 44px;
    margin-right: 8px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.15rem;
    flex: 0 0 44px;
}

.sidebar {
    width: min(86vw, 320px);
    top: 0;
    height: 100vh;
    padding: 0 0 20px;
    z-index: 1045;
}

.sidebar.mobile-offcanvas {
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.sidebar.mobile-offcanvas.show,
.sidebar.mobile-offcanvas.showing {
    visibility: visible;
    transform: none;
}

.sidebar.mobile-offcanvas.hiding {
    visibility: visible;
}

.sidebar a {
    min-height: 44px;
}

.mobile-sidebar-header {
    min-height: 72px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    color: #fff;
}

.mobile-sidebar-brand {
    font-weight: 700;
}

.mobile-sidebar-user {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
}

.mobile-sidebar-header .btn-close {
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    flex: 0 0 44px;
    background-size: 14px;
}

.mobile-sidebar-footer {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.main-content {
    width: 100%;
    margin-left: 0;
    padding: 18px 12px 24px;
}

.page-title {
    margin-bottom: 18px;
    font-size: 1.45rem;
}

@media (min-width: 768px) {
    body {
        overflow-x: visible;
    }

    .login-page {
        padding: 0;
    }

    .login-card {
        padding: 44px 40px;
    }

    .login-card .form-control {
        min-height: 0;
        font-size: 0.95rem;
    }

    .login-card .btn-login {
        min-height: 0;
        font-size: 0.98rem;
    }

    .login-logo {
        margin-bottom: 32px;
    }

    .mobile-menu-grid .btn {
        min-height: 0;
    }

    .sale-form {
        padding-bottom: 0;
    }

    .sale-form > .row > [class*="col-"] {
        margin-bottom: 0;
    }

    .sale-form .form-control,
    .sale-form .form-select {
        min-height: 0;
        font-size: 1rem;
    }

    .sale-form .btn-group > .btn {
        min-height: 0;
        display: inline-block;
    }

    .mobile-native-select {
        position: static;
        width: auto;
        height: auto;
        padding: 0.375rem 2.25rem 0.375rem 0.75rem;
        border: var(--bs-border-width) solid var(--bs-border-color);
        opacity: 1;
        pointer-events: auto;
        display: block;
    }

    .mobile-choice-grid {
        display: none;
    }

    .sale-form .form-switch {
        min-height: 0;
        display: block;
        padding-left: 2.5em;
    }

    .sale-form .form-switch .form-check-input {
        width: 2em;
        height: 1em;
        margin-top: 0.25em;
        margin-left: -2.5em;
    }

    .sale-submit {
        position: static;
        width: auto;
        min-height: 0;
        box-shadow: none;
    }

    .main-content .form-control,
    .main-content .form-select {
        min-height: 0;
        font-size: 1rem;
    }

    .main-content .btn:not(.sale-submit) {
        min-height: 0;
        display: inline-block;
    }

    .main-content .card-body {
        padding: var(--bs-card-spacer-y) var(--bs-card-spacer-x);
    }

    .main-content .card-dashboard .card-body {
        padding: 24px;
    }

    .main-content .container {
        --bs-gutter-x: 1.5rem;
        padding-right: calc(var(--bs-gutter-x) * 0.5);
        padding-left: calc(var(--bs-gutter-x) * 0.5);
    }

    .mobile-action-group {
        flex-direction: row;
    }

    .mobile-action-group .btn {
        width: auto;
    }

    .mobile-turn-item {
        align-items: center !important;
        flex-direction: row;
        gap: 0;
    }

    .topbar {
        padding: 0 22px;
    }

    .topbar .brand {
        font-size: 1.1rem;
    }

    .topbar .right {
        gap: 16px;
    }

    .topbar .role-badge,
    .topbar-user {
        display: inline;
    }

    .topbar-logout {
        min-height: 0;
        padding: 0;
        font-size: 0.82rem;
    }

    .mobile-menu-button,
    .mobile-sidebar-header,
    .mobile-sidebar-footer {
        display: none;
    }

    .sidebar {
        width: var(--sidebar-width);
        top: var(--topbar-height);
        height: auto;
        padding: 12px 0 20px;
        z-index: auto;
    }

    .sidebar a {
        min-height: 0;
    }

    .main-content {
        width: auto;
        margin-left: var(--sidebar-width);
        padding: 28px 30px;
    }

    .page-title {
        margin-bottom: 24px;
        font-size: calc(1.3rem + 0.6vw);
    }
}
