html,
body {
    min-width: 0;
}

body {
    overflow-x: hidden;
}

body.nav-open {
    overflow: hidden;
}

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

.cad-header-title-main,
.panel-heading,
.status,
.desc,
.field-value,
.map-footer,
.voice-radio-status {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Dispatch dashboard */
body:has(.cad-container) {
    overflow: auto;
}

.cad-container {
    min-height: calc(100dvh - 64px);
    height: auto !important;
}

.cad-panel,
.cad-map {
    min-height: 220px;
}

.cad-list {
    max-height: 100%;
}

@media (max-width: 1440px) {
    .cad-container {
        grid-template-columns: minmax(240px, 0.8fr) minmax(260px, 1fr) minmax(260px, 1fr) minmax(320px, 1.15fr);
    }

    .cad-btn,
    .modal-content button {
        padding-inline: 9px;
    }
}

@media (max-width: 1180px), (max-height: 760px) {
    .cad-header {
        height: auto !important;
        min-height: 64px;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .cad-container {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        grid-template-rows: none !important;
        align-items: stretch;
    }

    .cad-map,
    .bolo-board,
    .radio-board {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }

    .cad-map {
        min-height: 380px;
    }
}

@media (max-width: 760px) {
    .cad-header,
    .cad-container {
        grid-template-columns: 1fr !important;
    }

    .cad-header > div:nth-of-type(2) {
        min-width: 0;
        flex-wrap: wrap;
    }

    .radio-tabs,
    .bolo-board .cad-list {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .radio-compose,
    .voice-radio-controls {
        grid-template-columns: 1fr !important;
    }

    .cad-map {
        min-height: 320px;
    }
}

/* Department dashboards */
body:has(.cad-shell) {
    overflow: auto;
}

.cad-shell {
    min-height: 100dvh;
    height: auto !important;
}

.top-bar {
    min-height: 64px;
    isolation: isolate;
    position: relative;
    z-index: 80;
}

.main-stage {
    min-height: 0;
}

.call-main-column,
.erlc-map-panel,
.assigned-call-board {
    min-width: 0;
}

.status-group {
    max-width: 100%;
}

.status-btn,
.shift-btn,
.availability-btn,
.bottom-tab {
    min-width: 0;
    white-space: normal;
}

@media (max-width: 1280px), (max-height: 780px) {
    .top-bar {
        grid-template-columns: minmax(0, 1fr) auto auto !important;
        gap: 10px;
        padding: 8px 10px;
    }

    .top-left {
        gap: 8px;
    }

    .unit-badge {
        max-width: 220px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .top-tools,
    .shift-management {
        gap: 5px;
    }

    .bottom-tab {
        min-width: 96px;
        padding-inline: 8px;
    }

    .status-group {
        grid-template-columns: repeat(5, minmax(82px, 1fr)) !important;
        width: 100%;
    }

    .status-btn,
    .availability-btn {
        font-size: 11px;
        padding-inline: 6px;
    }
}

@media (max-width: 1100px), (max-height: 700px) {
    .cad-shell {
        grid-template-rows: auto auto auto !important;
    }

    .top-bar,
    .call-workspace {
        grid-template-columns: 1fr !important;
    }

    .top-left,
    .shift-management,
    .profile-menu {
        justify-self: stretch !important;
    }

    .profile-menu {
        justify-content: flex-start;
    }

    .shift-management {
        grid-template-columns: 1fr auto 1fr !important;
    }

    .form-grid,
    .form-grid.two-left {
        grid-template-columns: 1fr !important;
    }

    .call-main-column {
        grid-template-rows: auto minmax(150px, auto) auto auto !important;
    }

    .erlc-map-panel {
        min-height: 360px;
    }

    .bottom-bar {
        min-height: 58px;
        padding-block: 8px;
    }
}

/* Dashboard menu polish */
.profile-menu,
.log-menu,
.notification-menu,
.user-menu {
    position: relative;
    z-index: 120;
}

.profile-dropdown,
.log-dropdown,
.notif-dropdown,
.user-dropdown-menu,
#userDropdownMenu {
    z-index: 3200 !important;
    max-height: min(70dvh, 420px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(120, 170, 230, 0.18) !important;
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.42) !important;
}

.profile-dropdown a,
.log-dropdown button,
.user-dropdown-menu a,
.user-dropdown-menu button,
#userDropdownMenu a,
#userDropdownMenu button {
    white-space: nowrap;
}

.log-menu.is-open {
    z-index: 3300;
}

.log-menu.is-open + *,
.profile-menu:focus-within {
    z-index: 3400;
}

@media (max-width: 760px) {
    .top-bar,
    .top-left,
    .top-tools,
    .shift-management,
    .status-group,
    .lookup-form,
    .log-actions {
        grid-template-columns: 1fr !important;
        flex-direction: column;
        align-items: stretch;
    }

    .top-tools,
    .lookup-form,
    .log-actions {
        display: grid;
    }

    .brand-cluster {
        flex-wrap: wrap;
    }

    .unit-badge {
        max-width: 100%;
        white-space: normal;
    }

    .shift-time {
        min-width: 0;
    }

    .status-btn,
    .shift-btn,
    .availability-btn,
    .bottom-tab {
        width: 100%;
    }

    .erlc-map-panel {
        min-height: 300px;
    }
}

/* Site-wide responsive hardening */
img,
svg,
canvas,
video,
iframe {
    max-width: 100%;
}

table {
    max-width: 100%;
}

pre,
code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.container,
.page-shell,
.dx-footer-inner,
.standard-page,
.main-content,
.premium-page,
.docs-layout,
.auth-shell,
.verify-shell,
.application-shell,
.partners-shell,
.staff-shell,
.status-shell {
    min-width: 0;
}

.main-content,
.premium-page,
.standard-page,
.page-shell {
    overflow-x: clip;
}

/* Public/home pages */
@media (max-width: 1100px) {
    .navbar .container,
    .site-header,
    .dx-footer-top,
    .dx-footer-bottom,
    .login-brand,
    .auth-header {
        gap: 16px;
    }

    .hero-inner,
    .home-page .hero-inner,
    .feature-showcase,
    .dashboard-preview,
    .login-shell,
    .auth-shell,
    .verify-shell,
    .application-layout,
    .partners-layout,
    .staff-layout,
    .status-layout {
        grid-template-columns: 1fr !important;
    }

    .feature-grid,
    .feature-grid-pro,
    .ops-strip-grid,
    .workflow-grid,
    .pricing-grid,
    .home-page .pricing-grid,
    .premium-feature-grid,
    .premium-faq-grid,
    .docs-card-grid,
    .staff-grid,
    .partners-grid,
    .status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .command-shell {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .container {
        padding-inline: 16px !important;
    }

    .page-shell {
        width: min(100% - 28px, 1400px) !important;
    }

    .navbar {
        padding-block: 12px !important;
    }

    .nav-actions {
        display: none !important;
    }

    .nav-links {
        width: min(320px, calc(100vw - 32px)) !important;
    }

    .hero,
    .home-page .hero,
    .standard-page,
    .section,
    .pricing-section,
    .reviews-section,
    .workflow-section {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .hero-cta,
    .premium-hero-actions,
    .site-nav,
    .public-auth-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100%;
    }

    .hero-cta .btn,
    .premium-hero-actions a,
    .site-nav a,
    .site-nav button,
    .button {
        width: 100%;
    }

    .hero-proof,
    .feature-grid,
    .feature-grid-pro,
    .ops-strip-grid,
    .workflow-grid,
    .pricing-grid,
    .home-page .pricing-grid,
    .premium-feature-grid,
    .premium-faq-grid,
    .docs-card-grid,
    .staff-grid,
    .partners-grid,
    .status-grid,
    .dx-footer-top,
    .dx-footer-bottom {
        grid-template-columns: 1fr !important;
    }

    .shell-body {
        grid-template-columns: 1fr !important;
    }

    .ops-timeline {
        grid-template-columns: 1fr !important;
    }

    .call-row {
        grid-template-columns: 42px minmax(0, 1fr) !important;
    }

    .call-row small {
        grid-column: 2;
    }

    .reviews-grid {
        scroll-padding-inline: 16px;
    }

    .review-card {
        flex-basis: min(310px, calc(100vw - 44px)) !important;
    }

    .dx-footer-bottom,
    .dx-footer-badges {
        align-items: stretch !important;
    }
}

/* Documentation and public article pages */
@media (max-width: 1100px) {
    .docs-layout,
    .docs-shell,
    .docs-main-layout,
    .legal-layout {
        grid-template-columns: 1fr !important;
    }

    .docs-sidebar,
    .docs-toc {
        position: static !important;
        max-height: none !important;
        width: 100% !important;
    }
}

@media (max-width: 760px) {
    .docs-content,
    .legal-content,
    .standard-card,
    .doc-card,
    .dx-card {
        padding: 18px !important;
    }

    .docs-content table,
    .legal-content table,
    .dx-table,
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Sidebar dashboard shell */
@media (max-width: 1024px) {
    .dashboard-container {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        position: fixed !important;
        inset: 0 auto 0 0;
        width: min(300px, 86vw) !important;
        max-width: 86vw;
        transform: translateX(-104%);
        z-index: 2200;
    }

    .sidebar.active,
    .sidebar.is-open,
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
    }

    .sidebar-overlay.active,
    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .main-content {
        width: 100% !important;
        min-height: 100dvh;
        padding: 18px !important;
    }
}

@media (max-width: 760px) {
    .header,
    .dashboard-header,
    .premium-card-header,
    .premium-card-price-row,
    .roster-header,
    .servers-header,
    .profile-header,
    .manage-header {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        align-items: stretch !important;
    }

    .premium-hero,
    .premium-allocation,
    .premium-feature-section,
    .premium-plan-section,
    .premium-faq-section,
    .roster-panel,
    .profile-panel,
    .servers-panel,
    .manage-panel,
    .settings-panel {
        padding: 18px !important;
        border-radius: 12px !important;
    }

    .premium-title,
    .profile-title,
    .roster-title,
    .servers-title,
    .manage-title {
        font-size: clamp(2rem, 11vw, 3rem) !important;
        line-height: 1.02 !important;
        letter-spacing: 0 !important;
    }

    .premium-cards-row,
    .premium-allocation-steps,
    .profile-grid,
    .roster-grid,
    .server-grid,
    .settings-grid,
    .manage-grid,
    .activity-grid,
    .department-grid,
    .premium-feature-grid,
    .premium-faq-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .premium-card {
        min-width: 0 !important;
        width: 100% !important;
        max-width: none !important;
        padding: 22px !important;
    }

    .premium-usd-meta,
    .profile-actions,
    .roster-actions,
    .server-actions,
    .settings-actions,
    .form-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .premium-card-btn,
    .premium-card-btn-plus,
    .premium-card-btn-stripe,
    .profile-action,
    .roster-action,
    .server-action,
    .activity-save-btn,
    .erlc-save-btn,
    .discord-save-btn,
    .departments-save-btn {
        width: 100% !important;
    }
}

/* Department/CAD dashboards */
@media (max-width: 980px) {
    .cad-header {
        padding: 10px !important;
    }

    .cad-container {
        padding: 10px !important;
        gap: 10px !important;
    }

    .top-bar {
        position: static !important;
    }

    .main-stage {
        padding: 10px !important;
    }

    .bottom-bar {
        position: static !important;
    }
}

@media (max-width: 560px) {
    .cad-panel,
    .bolo-board,
    .radio-board,
    .cad-map,
    .field,
    .call-description,
    .units-panel,
    .dept-radio-panel,
    .assigned-call-board,
    .erlc-map-panel,
    .lookup-panel,
    .log-modal-panel {
        border-radius: 10px !important;
        padding: 12px !important;
    }

    .radio-tabs,
    .status-group {
        grid-template-columns: 1fr !important;
    }

    .modal-content,
    .lookup-profile-modal {
        width: min(100% - 24px, 620px) !important;
        max-height: 88dvh !important;
        overflow: auto !important;
        padding: 18px !important;
    }

    .lookup-profile-head,
    .lookup-profile-grid {
        grid-template-columns: 1fr !important;
    }
}
