/* SGI responsive polish loaded after the compiled Vite bundle. */

/* Reserve the fixed dock area instead of letting dialogs continue behind it. */
.modal-backdrop {
    z-index: 55 !important;
    box-sizing: border-box;
    display: grid !important;
    place-items: center !important;
    overflow: hidden !important;
    padding: max(.75rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) calc(6.5rem + env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left)) !important;
}

.modal-card {
    display: flex !important;
    width: min(40rem, 100%) !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 8rem - env(safe-area-inset-bottom)) !important;
    flex-direction: column !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.modal-header {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: .75rem !important;
    padding: 1rem 1.1rem .8rem !important;
}

.modal-header > div {
    min-width: 0;
    flex: 1 1 auto;
}

.modal-header h3,
.modal-header p {
    overflow-wrap: anywhere;
}

.modal-header .icon-button {
    flex: 0 0 auto;
    margin-left: auto !important;
}

.modal-body {
    min-height: 0 !important;
    flex: 1 1 auto !important;
    margin-top: 0 !important;
    padding: .35rem 1.1rem 1rem !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: .65rem !important;
    margin-top: 0 !important;
    padding: .85rem 1.1rem 1rem !important;
    border-top: 1px solid var(--border-strong);
    background: color-mix(in srgb, var(--bg-strong) 90%, transparent);
}

@media (max-width: 760px) {
    .topbar {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: .75rem !important;
        padding: .9rem !important;
    }

    .topbar-brand {
        align-items: flex-start !important;
    }

    .topbar-brand > div {
        min-width: 0;
    }

    .topbar-brand h1 {
        font-size: clamp(1.35rem, 6vw, 1.75rem) !important;
        line-height: 1.15 !important;
        overflow-wrap: anywhere;
    }

    .topbar-logo {
        width: 2.7rem !important;
        height: 2.7rem !important;
    }

    .topbar-context {
        width: 100% !important;
        gap: .35rem !important;
    }

    .topbar-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto auto !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: .5rem !important;
        width: 100% !important;
    }

    .topbar-actions .profile-chip {
        display: grid !important;
        min-width: 0 !important;
        width: 100% !important;
        gap: .1rem !important;
        padding: .6rem .75rem !important;
        overflow: hidden;
    }

    .topbar-actions .profile-chip span,
    .topbar-actions .profile-chip small {
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-actions .profile-chip small {
        font-size: .74rem;
    }

    .topbar-actions .icon-button {
        width: 2.65rem !important;
        height: 2.65rem !important;
    }

    .page-header {
        gap: .75rem !important;
    }

    .page-header h2 {
        font-size: clamp(1.45rem, 6.5vw, 1.85rem) !important;
        line-height: 1.15 !important;
        overflow-wrap: anywhere;
    }

    .page-actions {
        display: grid !important;
        width: 100% !important;
        grid-template-columns: minmax(6.5rem, .75fr) minmax(0, 1.25fr) !important;
        flex-direction: row !important;
        gap: .55rem !important;
    }

    .page-actions .control-select,
    .page-actions .btn {
        min-width: 0 !important;
        width: 100% !important;
    }

    .modal-backdrop {
        padding: max(.5rem, env(safe-area-inset-top)) max(.5rem, env(safe-area-inset-right)) calc(6.15rem + env(safe-area-inset-bottom)) max(.5rem, env(safe-area-inset-left)) !important;
    }

    .modal-card {
        width: 100% !important;
        max-height: calc(100dvh - 7.15rem - env(safe-area-inset-bottom)) !important;
        border-radius: 1.3rem !important;
    }

    .modal-header {
        flex-direction: row !important;
        align-items: flex-start !important;
        padding: .85rem .9rem .7rem !important;
    }

    .modal-header h3 {
        font-size: 1.12rem !important;
    }

    .modal-header p {
        font-size: .82rem !important;
        line-height: 1.35 !important;
    }

    .modal-body {
        padding: .25rem .9rem .9rem !important;
    }

    .modal-footer {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        align-items: stretch !important;
        padding: .75rem .9rem .85rem !important;
    }

    .modal-footer .btn {
        min-width: 0 !important;
        width: 100% !important;
        justify-content: center !important;
        padding-inline: .65rem !important;
    }

    .modal-body .split-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .day-input {
        max-width: 100% !important;
    }
}

@media (max-width: 430px) {
    .topbar-actions {
        grid-template-columns: minmax(0, 1fr) 2.65rem 2.65rem !important;
    }

    .page-actions {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .modal-footer {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}
