html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overscroll-behavior-y: contain;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.navbar-custom {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.navbar-custom .navbar-brand {
    font-size: clamp(0.92rem, 2.2vw, 1.2rem);
    white-space: normal;
    line-height: 1.3;
}

.section-dashboard .container.mt-4,
.section-reports .container.mt-4 {
    margin-top: 1.15rem !important;
}

.section-dashboard .main-content,
.section-reports .main-content {
    padding: 1.25rem;
    border-radius: 14px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.section-dashboard .table-responsive,
.section-reports .table-responsive {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: thin;
}

.section-dashboard .table-wrapper,
.section-reports .table-wrapper {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.section-dashboard .table td,
.section-dashboard .table th,
.section-reports .table td,
.section-reports .table th {
    white-space: normal;
}

.section-dashboard .form-control,
.section-dashboard .form-select,
.section-reports .form-control,
.section-reports .form-select,
.section-dashboard .input-group-text,
.section-reports .input-group-text {
    min-height: 44px;
}

@media (max-width: 992px) {
    .section-dashboard .card-body,
    .section-reports .card-body {
        padding: 1rem;
    }

    .section-dashboard h1,
    .section-dashboard h2,
    .section-reports h1,
    .section-reports h2 {
        font-size: 1.45rem;
        line-height: 1.3;
    }

    .navbar-custom .navbar-collapse {
        padding-top: 0.75rem;
    }
}

@media (max-width: 768px) {
    .section-dashboard .container.mt-4,
    .section-reports .container.mt-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .section-dashboard .main-content,
    .section-reports .main-content {
        padding: 0.95rem;
        border-radius: 12px;
    }

    .navbar-custom .navbar-brand {
        max-width: 78%;
    }

    .navbar-custom .navbar-nav {
        gap: 0.2rem;
    }

    .navbar-custom .nav-link {
        padding-left: 0.7rem;
        padding-right: 0.7rem;
        width: 100%;
    }

    .section-dashboard .card-header,
    .section-reports .card-header {
        padding: 0.8rem 0.95rem;
        font-size: 0.9rem;
    }

    .section-dashboard .dashboard-tabs-wrap,
    .section-dashboard .admin-tabs-wrap {
        padding: 8px;
        border-radius: 12px;
    }

    .section-dashboard .dashboard-tabs-wrap .nav-pills,
    .section-dashboard .admin-tabs-wrap .nav-pills {
        gap: 7px;
    }

    .section-dashboard .dashboard-tabs-wrap .nav-link,
    .section-dashboard .admin-tabs-wrap .nav-link {
        padding: 0.72rem 0.78rem;
        min-height: 44px;
        font-size: 0.88rem;
    }

    .section-dashboard .table,
    .section-reports .table {
        font-size: 0.84rem;
    }

    .section-dashboard .table thead th,
    .section-reports .table thead th {
        font-size: 0.76rem;
        letter-spacing: 0.02em;
        padding: 0.65rem 0.7rem;
    }

    .section-dashboard .table tbody td,
    .section-reports .table tbody td {
        padding: 0.65rem 0.7rem;
    }

    .section-dashboard .form-control,
    .section-dashboard .form-select,
    .section-reports .form-control,
    .section-reports .form-select {
        font-size: 0.92rem;
        padding: 0.62rem 0.8rem;
    }

    .section-dashboard .input-group-text,
    .section-reports .input-group-text {
        padding: 0.62rem 0.78rem;
        font-size: 0.84rem;
    }

    .section-dashboard .badge,
    .section-reports .badge {
        font-size: 0.72rem;
        padding: 0.34rem 0.68rem;
    }
}

@media (max-width: 480px) {
    .section-dashboard h1,
    .section-dashboard h2,
    .section-reports h1,
    .section-reports h2,
    .workspace-page-title {
        font-size: 1.35rem;
    }

    .section-dashboard p,
    .section-dashboard .text-muted,
    .section-reports p,
    .section-reports .text-muted {
        font-size: 0.92rem;
    }

    .section-dashboard .form-label,
    .section-reports .form-label {
        font-size: 0.84rem;
        margin-bottom: 0.45rem;
    }

    .section-dashboard .form-control,
    .section-dashboard .form-select,
    .section-reports .form-control,
    .section-reports .form-select,
    .form-control,
    .form-select,
    .form-control-sm,
    .form-select-sm {
        min-height: 44px;
        font-size: 16px;
        padding: 0.55rem 0.75rem;
    }

    .section-dashboard .table-wrapper,
    .section-reports .table-wrapper {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .section-dashboard .card,
    .section-reports .card {
        border-radius: 12px;
    }
}

@media (max-width: 767.98px) {
    .btn,
    .btn-sm,
    .btn-sm:not(.btn-link),
    .table td .btn,
    .table td:last-child .btn,
    .btn-view-hw,
    .distance-view-btn {
        min-height: 44px;
        white-space: normal;
        text-align: center;
    }

    .d-flex.gap-1,
    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap;
    }

    .card-header {
        align-items: stretch;
    }

    .card-header > .btn,
    .card-header > .btn-group,
    .card-footer > .btn,
    .card-footer .btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .d-flex.gap-1 > .btn,
    .d-flex.gap-2 > .btn,
    .d-flex.gap-3 > .btn,
    .d-flex.gap-1 > form,
    .d-flex.gap-2 > form,
    .d-flex.gap-3 > form {
        flex: 1 1 12rem;
    }

    .d-flex.gap-1 > form .btn,
    .d-flex.gap-2 > form .btn,
    .d-flex.gap-3 > form .btn {
        width: 100%;
    }

    .input-group > .btn {
        flex: 0 0 44px;
        min-width: 44px;
        width: auto;
    }

    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-dialog {
        margin: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .d-flex.justify-content-between.gap-2,
    .d-flex.justify-content-between.gap-3,
    .d-flex.justify-content-end.gap-2,
    .d-flex.justify-content-end.gap-3 {
        flex-wrap: wrap;
        align-items: stretch;
    }

    .d-flex.justify-content-between.gap-2 > .btn,
    .d-flex.justify-content-between.gap-3 > .btn,
    .d-flex.justify-content-end.gap-2 > .btn,
    .d-flex.justify-content-end.gap-3 > .btn,
    .d-flex.gap-2 > .btn,
    .d-flex.gap-3 > .btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .workspace-page-header .btn,
    .ag-toolbar .btn,
    .ds-toolbar .btn {
        width: 100%;
    }

    .ag-toolbar,
    .ds-toolbar {
        justify-content: stretch;
    }
}
