:root {
    --touch-size: 44px;
}

input,
select,
textarea,
button,
.btn,
.ui-btn {
    min-height: var(--touch-size);
}

.mobile-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.52);
    z-index: 60;
}

.modal-shell {
    padding: 16px;
}
.modal-shell-panel {
    width: min(96vw, 1500px);
    max-height: 92vh;
}
.modal-shell-header {
    position: sticky;
    top: 0;
    z-index: 30;
}
.modal-shell-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}
.modal-shell-actions button {
    min-height: var(--touch-size);
}
.modal-shell-body {
    overflow-x: hidden;
}
.modal-shell-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 84px;
        overflow: hidden;
    }
    .sidebar .section-title,
    .sidebar .section-btn span,
    .sidebar .section-btn i.fa-chevron-down,
    .sidebar .section-btn i.fa-chevron-right,
    .sidebar .nav-btn span {
        display: none;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 10px 12px !important;
    }
    main {
        padding: 12px !important;
        padding-bottom: 88px !important;
    }
    .sidebar {
        position: fixed !important;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 320px) !important;
        transform: translateX(-102%);
        transition: transform .22s ease;
        z-index: 70;
        overflow-y: auto;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar .section-title,
    .sidebar .section-btn span,
    .sidebar .section-btn i.fa-chevron-down,
    .sidebar .section-btn i.fa-chevron-right,
    .sidebar .nav-btn span {
        display: initial;
    }
    .sidebar .nav-btn,
    .sidebar .section-btn {
        padding-top: 11px !important;
        padding-bottom: 11px !important;
    }
    .quick-panel-card {
        width: 100% !important;
        height: min(92vh, 92vh) !important;
        border-radius: 14px !important;
    }
    .modal-shell {
        padding: 8px !important;
        align-items: flex-end !important;
    }
    .modal-shell-panel {
        width: calc(100vw - 12px) !important;
        max-width: 100% !important;
        height: min(94dvh, 94vh) !important;
        max-height: min(94dvh, 94vh) !important;
        border-radius: 14px 14px 0 0 !important;
        overflow: hidden !important;
    }
    .modal-shell-body {
        max-height: calc(94dvh - 150px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 12px !important;
    }
    .modal-shell-header {
        padding: 12px !important;
    }
    .modal-shell-actions {
        width: 100%;
        gap: 8px !important;
    }
    .modal-shell-actions button {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
    }
    .project-modal-grid,
    .budget-modal-body,
    .order-modal-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .budget-summary-card,
    .order-modal-aside {
        position: static !important;
        top: auto !important;
        border-left: 0 !important;
        border-top: 1px solid rgba(148, 163, 184, 0.25);
    }
    .order-wizard-tabs {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        white-space: nowrap;
    }
    .order-wizard-tabs button {
        flex: 0 0 auto;
    }
    .project-modal-body .grid,
    .budget-modal-body .grid,
    .order-modal-main .grid {
        grid-template-columns: 1fr !important;
    }
    .project-modal-body .grid.grid-cols-2 {
        grid-template-columns: 1fr 1fr !important;
    }
    .project-modal-body .grid.grid-cols-4 {
        grid-template-columns: 1fr 1fr !important;
    }
    .project-modal-body .overflow-auto,
    .project-modal-body .overflow-x-auto,
    .budget-modal-body .overflow-auto,
    .budget-modal-body .overflow-x-auto,
    .order-modal-main .overflow-auto,
    .order-modal-main .overflow-x-auto {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
        border-radius: 16px 16px 0 0 !important;
        padding: 16px !important;
    }
    .page-a4 {
        width: 100% !important;
        min-height: auto !important;
        margin: 10px 0 !important;
        padding: 8px !important;
    }
    .table-responsive,
    .overflow-x-auto table,
    main table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    .user-chip-dropdown {
        right: -8px !important;
        min-width: 168px !important;
    }
}

@media (max-width: 480px) {
    .topbar .pill {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }
    .topbar .user-chip {
        padding: 5px 8px !important;
        font-size: 12px !important;
    }
    .topbar .user-chip span {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .modal-shell-panel {
        width: calc(100vw - 8px) !important;
        height: min(96dvh, 96vh) !important;
        max-height: min(96dvh, 96vh) !important;
    }
    .modal-shell-header h3 {
        font-size: 1rem !important;
        line-height: 1.35 !important;
    }
    .modal-shell-actions button {
        flex: 1 1 100%;
    }
    .project-modal-body .grid.grid-cols-2,
    .project-modal-body .grid.grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
}
