/*
 * KEYS responsive presentation layer
 * Mobile/tablet-only normalization. No business logic or data behavior belongs here.
 */

html {
    min-width: 320px;
    overflow-x: hidden;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    overflow-x: hidden;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
}

main,
section,
article,
form,
fieldset,
.table_wrap,
.ui_page_body,
.keys_surface_body,
.content-wrap,
.page_panel,
.page_card,
.card,
.content_card {
    min-width: 0;
}

button,
a,
input,
select,
textarea,
summary {
    touch-action: manipulation;
}

/* -------------------------------------------------------------------------
   Tablet foundation
   ------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    button,
    .ui_action_btn,
    .venue-nav-link,
    .venue-action-link,
    .platform-btn,
    .platform-submit,
    .public_shell_link,
    .admin_shell_link,
    .abc_shell_link,
    .door-button,
    .door-link,
    .claim-button,
    .claim-button-secondary,
    .minutes-btn,
    .minutes-link,
    .queue-btn,
    .queue-link,
    .action-button,
    .action-button-secondary {
        min-height: 44px;
    }

    .page_main {
        padding-top: 14px;
        padding-bottom: 24px;
    }

    .page_panel {
        padding: 18px;
        border-radius: 18px;
    }

    .ui_page_header,
    .keys_surface_header,
    .approved_shell_header,
    .users-shell-header,
    .venue-shell-header {
        scroll-margin-top: 12px;
    }

    .table_wrap {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable;
    }

    .data_table,
    table {
        font-size: 0.94rem;
    }

    .data_table th,
    .data_table td,
    th,
    td {
        padding: 12px;
    }

    .modal-backdrop,
    .kiosk_modal,
    .door-modal,
    .door-traffic-modal,
    .retention-modal,
    .door-analytics-modal {
        overscroll-behavior: contain;
    }

    .kiosk_modal__panel,
    .door-modal__panel,
    .door-traffic-modal__dialog,
    .retention-modal__panel,
    .door-analytics-modal-panel,
    .member-detail-modal-card,
    .venue-modal-card {
        max-height: calc(100dvh - 28px);
        overflow: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep two-column information groups useful in tablet portrait. */
    .member-detail-info-grid,
    .member-detail-summary-grid,
    .member-detail-section-grid,
    .member-detail-payment-tiles,
    .member-detail-quickpay-grid,
    .workflow-grid,
    .compliance-kpi-grid,
    .queue-summary-grid,
    .minutes-kpi-row {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* -------------------------------------------------------------------------
   Venue shell: compact tablet and phone chrome
   ------------------------------------------------------------------------- */
@media (max-width: 1080px) {
    .shell-page {
        padding: 8px 8px 22px !important;
    }

    .venue-shell-top {
        grid-template-columns: minmax(160px, 240px) minmax(0, 1fr) !important;
        grid-template-areas:
            "brand center"
            "meta meta";
        gap: 10px 14px !important;
        padding: 12px 14px !important;
        text-align: left !important;
    }

    .venue-brand {
        grid-area: brand;
        min-height: 52px !important;
        justify-content: flex-start !important;
    }

    .venue-brand img {
        width: min(220px, 100%) !important;
        max-height: 58px;
        object-fit: contain;
        object-position: left center;
    }

    .venue-center {
        grid-area: center;
        text-align: right !important;
        min-width: 0;
    }

    .venue-center-title {
        font-size: clamp(20px, 3vw, 25px) !important;
        overflow-wrap: anywhere;
    }

    .venue-meta {
        grid-area: meta;
        display: flex !important;
        flex-wrap: wrap;
        justify-content: flex-end !important;
        justify-items: stretch !important;
        gap: 8px !important;
        min-width: 0 !important;
    }

    .venue-meta-pill {
        min-width: 0 !important;
        flex: 0 1 auto;
        padding: 6px 10px !important;
    }

    .venue-meta-pill--accent {
        order: -1;
    }

    .venue-shell-nav-row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px !important;
        padding: 9px 10px !important;
    }

    .venue-nav-group {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 2px;
    }

    .venue-nav-link,
    .venue-action-link {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .venue-logout-group {
        flex-wrap: nowrap !important;
    }

    .venue-notification-row {
        align-items: flex-start !important;
        padding: 9px 10px !important;
    }

    .venue-notification-group {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 2px;
    }

    .content-wrap {
        padding: 14px 12px 22px !important;
    }

    .platform-shell-toggle,
    .platform-shell-bar,
    .sim-banner {
        margin: 10px !important;
    }
}

/* -------------------------------------------------------------------------
   Phone foundation
   ------------------------------------------------------------------------- */
@media (max-width: 720px) {
    .site_shell,
    .site_shell_public,
    .site_shell_wide,
    .site_shell_narrow {
        width: calc(100% - 16px) !important;
    }

    .shell-page {
        padding: 6px 6px 18px !important;
    }

    .page_main {
        padding: 8px 0 18px;
    }

    .page_panel {
        padding: 12px;
        border-radius: 16px;
    }

    .content-wrap {
        padding: 12px 8px 18px !important;
        gap: 12px !important;
    }

    .ui_page_header,
    .keys_surface_header,
    .approved_shell_header,
    .users-shell-header,
    .venue-shell-header {
        padding: 15px 14px 13px !important;
        border-radius: 16px !important;
    }

    .ui_page_title,
    .keys_surface_header .ui_page_title,
    .approved_shell_title,
    .users-shell-title,
    .venue-shell-title,
    .page_title {
        font-size: clamp(1.55rem, 7vw, 1.75rem) !important;
        line-height: 1.12 !important;
        overflow-wrap: anywhere;
    }

    .ui_page_subtitle,
    .approved_shell_subtitle,
    .users-shell-subtitle,
    .venue-shell-subtitle,
    .page_subtitle {
        font-size: 0.86rem !important;
        line-height: 1.42 !important;
    }

    .ui_page_header__row,
    .keys_surface_header_row,
    .page_intro,
    .page_intro_split,
    .ui_section_intro,
    .member_list_main_card_header,
    .compliance-card-head,
    .queue-head--with-action,
    .payments_drilldown_header {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .ui_page_header__meta,
    .keys_surface_header_meta {
        justify-content: flex-start !important;
    }

    .ui_page_header__note {
        max-width: none;
        width: 100%;
    }

    .ui_action_shelf,
    .keys_surface_action_shelf,
    .approved_shell_action_shelf,
    .member_list_action_shelf {
        padding: 14px !important;
        border-radius: 15px !important;
    }

    .ui_action_buttons,
    .page_intro_actions,
    .filter_actions,
    .member_list_action_shelf_actions,
    .member_list_pager_actions,
    .payments_drilldown_actions,
    .queue-actions,
    .queue-card-actions,
    .minutes-actions,
    .action-row,
    .door-actions,
    .session-actions,
    .inline-form,
    .modal-actions,
    .ui_modal_footer {
        width: 100%;
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 9px !important;
        justify-content: stretch !important;
    }

    .ui_action_buttons > *,
    .page_intro_actions > *,
    .filter_actions > *,
    .member_list_action_shelf_actions > *,
    .member_list_pager_actions > *,
    .payments_drilldown_actions > *,
    .queue-actions > *,
    .queue-card-actions > *,
    .minutes-actions > *,
    .action-row > *,
    .door-actions > *,
    .session-actions > *,
    .inline-form > *,
    .modal-actions > *,
    .ui_modal_footer > * {
        width: 100% !important;
        max-width: none !important;
    }

    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    textarea {
        min-height: 110px;
    }

    .metric_grid,
    .detail_grid,
    .member-detail-info-grid,
    .member-detail-summary-grid,
    .member-detail-section-grid,
    .member-detail-payment-tiles,
    .member-detail-quickpay-grid,
    .member-detail-action-grid,
    .workflow-grid,
    .compliance-kpi-grid,
    .queue-summary-grid,
    .queue-kpi-phase-wrap,
    .queue-info-grid,
    .queue-readiness-wrap,
    .queue-status-grid,
    .minutes-kpi-row,
    .minutes-grid-top,
    .claim-grid,
    .claim-row {
        grid-template-columns: 1fr !important;
    }

    .metric_card {
        min-height: 0;
    }

    .metric_value {
        font-size: 1.7rem;
    }

    .table_wrap {
        margin-right: -4px;
        border-radius: 12px;
    }

    .data_table {
        min-width: 680px;
    }

    .data_table th,
    .data_table td,
    th,
    td {
        padding: 10px;
    }

    .pagination,
    .member_list_pager {
        align-items: stretch !important;
    }

    /* Compact the top shell instead of stacking three full-height blocks. */
    .venue-shell {
        border-radius: 15px !important;
    }

    .venue-shell-top {
        grid-template-columns: minmax(120px, 0.9fr) minmax(0, 1.1fr) !important;
        grid-template-areas:
            "brand center"
            "meta meta";
        padding: 10px !important;
        gap: 8px 10px !important;
    }

    .venue-brand {
        min-height: 44px !important;
    }

    .venue-brand img {
        width: min(175px, 100%) !important;
        max-height: 48px;
    }

    .venue-brand-title {
        font-size: 18px !important;
    }

    .venue-center-title {
        font-size: clamp(17px, 5vw, 21px) !important;
    }

    .venue-center-sub {
        font-size: 11px !important;
    }

    .venue-meta {
        justify-content: stretch !important;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .venue-meta-pill {
        width: 100%;
        padding: 6px 8px !important;
    }

    .venue-meta-pill--accent {
        grid-column: 1 / -1;
    }

    .venue-meta-label {
        font-size: 9px !important;
    }

    .venue-meta-value {
        font-size: 12px !important;
        overflow-wrap: anywhere;
    }

    .venue-shell-nav-row {
        grid-template-columns: minmax(0, 1fr) auto !important;
        padding: 8px !important;
    }

    .venue-nav-group {
        width: 100%;
        padding: 0 0 4px;
    }

    .venue-nav-link,
    .venue-action-link,
    .platform-submit {
        min-height: 42px !important;
        border-radius: 11px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        font-size: 0.83rem;
    }

    .venue-logout-group,
    .venue-logout-group form {
        width: auto;
    }

    .venue-notification-row {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        padding: 9px 8px !important;
    }

    .venue-notification-copy {
        display: flex !important;
        align-items: baseline;
        gap: 8px !important;
        min-width: 0 !important;
    }

    .venue-notification-group {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        gap: 8px !important;
        overflow: visible;
    }

    .venue-notification-group > * {
        min-width: 0;
        width: 100%;
    }

    .venue-notification-group .venue-action-link {
        width: 100%;
    }

    .action-center-drawer {
        width: 100vw !important;
        max-width: none !important;
        padding: 14px !important;
        border-left: 0 !important;
    }

    .action-center-head {
        position: sticky;
        top: -14px;
        z-index: 2;
        padding: 14px 0 12px;
        background: #091b3b;
    }

    .action-center-group summary {
        padding: 13px 12px !important;
    }

    .manager-review-toast {
        top: 10px !important;
        right: 10px !important;
        width: calc(100vw - 20px) !important;
    }

    .platform-shell-toggle,
    .platform-shell-bar,
    .sim-banner {
        margin: 8px !important;
        padding: 11px !important;
    }

    .platform-shell-toggle,
    .platform-bar-head,
    .platform-view-form {
        align-items: stretch !important;
    }

    .platform-view-form > *,
    .platform-shell-toggle form,
    .platform-shell-toggle .platform-submit {
        width: 100%;
    }

    /* Kiosk and door operation surfaces */
    .approved_shell_page,
    .door-screen,
    .claim-page,
    .kiosk_lower_grid {
        gap: 12px !important;
    }

    .approved_shell_card,
    .door-card,
    .claim-card,
    .decision-panel,
    .queue-card,
    .minutes-card,
    .compliance-card,
    .venue-card {
        border-radius: 15px !important;
    }

    .approved_shell_card_body,
    .door-card__body,
    .claim-body,
    .queue-body,
    .minutes-body,
    .compliance-body,
    .venue-body {
        padding: 14px !important;
    }

    .door-title,
    .claim-title,
    .queue-title,
    .minutes-title,
    .compliance-card-title,
    .venue-card-title,
    .users-card-title {
        font-size: clamp(1.45rem, 7vw, 1.7rem) !important;
    }

    .door-scanner-box {
        min-height: 240px !important;
        padding: 8px !important;
    }

    .session-bar {
        grid-template-columns: 1fr !important;
        padding: 12px !important;
    }

    .identity-strip,
    .member-head,
    .door-title-strip,
    .door-modal__head,
    .kiosk_modal__head,
    .modal-head,
    .door-traffic-modal__head {
        align-items: stretch !important;
    }

    .identity-strip__id {
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .charge-row {
        align-items: flex-start !important;
    }

    .door-payment-methods {
        display: grid !important;
        grid-template-columns: 1fr;
    }

    .door-payment-method {
        width: 100%;
        min-height: 46px;
    }

    .door-modal,
    .kiosk_modal {
        padding: 8px !important;
        align-items: end !important;
    }

    .door-modal__panel,
    .kiosk_modal__panel,
    .retention-modal__panel,
    .venue-modal-card {
        width: 100% !important;
        max-width: none !important;
        max-height: calc(100dvh - 16px) !important;
        border-radius: 18px 18px 10px 10px !important;
        padding: 14px !important;
    }

    .door-traffic-modal__dialog,
    .door-analytics-modal-panel {
        width: calc(100vw - 12px) !important;
        max-height: calc(100dvh - 12px) !important;
        margin: 6px auto !important;
        border-radius: 14px !important;
    }

    .door-traffic-modal__body,
    .door-analytics-modal-body {
        max-height: calc(100dvh - 92px) !important;
        padding: 10px !important;
    }

    .kiosk_modal__summary,
    .payment_qr_panel,
    .door-qr-panel,
    .identity_verify_grid,
    .find-member-layout,
    .decision_banner,
    .decision_kpi_row,
    .id_bar,
    .operations_kpi_grid,
    .operations_kpi_grid--expanded,
    .activity_row,
    .activity_row--compact {
        grid-template-columns: 1fr !important;
    }

    .payment_qr_canvas,
    .door-qr-canvas {
        min-width: 0 !important;
        width: 100% !important;
    }

    .activity_row,
    .activity_row--compact {
        padding: 12px !important;
    }

    .activity_row > :last-child {
        justify-self: stretch !important;
    }

    /* Management surfaces */
    .member-detail-header-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .member-detail-id-box {
        padding: 16px !important;
    }

    .member-detail-id-number {
        font-size: 25px !important;
        overflow-wrap: anywhere;
    }

    .member-detail-hero-title {
        font-size: 26px !important;
    }

    .member-detail-utility-left,
    .member-detail-utility-right,
    .member-detail-button-wrap {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100%;
    }

    .member-detail-btn,
    .member-detail-button-wrap > *,
    .member-detail-utility-left > *,
    .member-detail-utility-right > * {
        width: 100%;
        white-space: normal !important;
        min-height: 44px;
    }

    .member-detail-modal-card {
        margin: 0 auto !important;
    }

    .member_list_action_shelf_fields,
    .member_list_action_shelf,
    .member_list_action_shelf_actions {
        grid-template-columns: 1fr !important;
    }

    .member_list_main_card_header,
    .member_list_main_card_body,
    .member_list_action_shelf {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

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

    .payments_calendar_cell {
        min-height: 0 !important;
    }

    .payments_hero_value {
        font-size: 34px !important;
    }

    .payments-live-status,
    .door-live-status,
    .queue-live-status {
        margin-left: 0 !important;
        width: 100%;
    }

    .week-strip,
    .venue-field-grid,
    .venue-grid-two,
    .snapshot-meta,
    .modal-grid,
    .modal-grid.modal-grid--four,
    .payment-method-grid {
        grid-template-columns: 1fr !important;
    }

    .week-day-card {
        min-height: 0 !important;
    }

    .venue-modal {
        width: calc(100% - 12px) !important;
        max-height: calc(100dvh - 12px);
        margin: 6px;
    }

    .modal-head,
    .modal-body,
    .venue-card-head {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .modal-toggle-row,
    .ui_segmented {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .modal-toggle-row > *,
    .ui_segmented > * {
        width: 100%;
    }

    .ui_toggle_row {
        align-items: stretch !important;
        flex-direction: column;
    }

    .ui_toggle_btn {
        width: 100%;
    }

    .queue-kpi,
    .workflow-card {
        min-height: 126px !important;
        height: auto !important;
    }

    .queue-kpi-value,
    .workflow-value,
    .minutes-kpi-value {
        font-size: 34px !important;
    }

    .minutes-workspace {
        grid-template-columns: 1fr !important;
    }

    .minutes-draft-panel {
        position: static !important;
    }

    .member-row-one,
    .member-row-two,
    .member-row-three {
        grid-template-columns: 1fr !important;
    }

    .decision-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
    }

    .decision-btn {
        width: 100%;
        min-height: 44px;
    }

    .audit-toolbar,
    .audit-feed-card {
        grid-template-columns: 1fr !important;
    }

    .audit-row-actions,
    .audit-live-controls {
        width: 100%;
    }

    .audit-row-actions > *,
    .audit-live-controls > button {
        flex: 1 1 auto;
    }

    /* Legacy admin/ABC shell layouts */
    .public_shell_header_top,
    .admin_shell_header_top,
    .abc_shell_header_top,
    .abc-shell-bar {
        padding: 14px !important;
        border-radius: 16px 16px 0 0 !important;
    }

    .public_shell_nav,
    .admin_shell_nav,
    .abc_shell_nav,
    .abc-action-row {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding: 10px 14px 12px !important;
        border-radius: 0 0 16px 16px !important;
        -webkit-overflow-scrolling: touch;
    }

    .public_shell_link,
    .admin_shell_link,
    .abc_shell_link,
    .abc-button-secondary,
    .abc-button-neutral,
    .abc-queue-pill {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .abc-action-left,
    .abc-action-right {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        width: auto !important;
    }

    .abc-session-summary-right {
        flex-direction: column;
        align-items: flex-end !important;
    }
}

@media (max-width: 420px) {
    .site_shell,
    .site_shell_public,
    .site_shell_wide,
    .site_shell_narrow {
        width: calc(100% - 10px) !important;
    }

    .venue-shell-top {
        grid-template-columns: 1fr !important;
        grid-template-areas:
            "brand"
            "center"
            "meta";
    }

    .venue-brand,
    .venue-center {
        justify-content: center !important;
        text-align: center !important;
    }

    .venue-brand img {
        object-position: center;
    }

    .venue-meta {
        grid-template-columns: 1fr;
    }

    .venue-meta-pill--accent {
        grid-column: auto;
    }

    .venue-notification-group {
        grid-template-columns: 1fr !important;
    }

    .venue-notification-copy {
        display: grid !important;
    }

    .modal-toggle-row,
    .ui_segmented,
    .decision-row {
        grid-template-columns: 1fr !important;
    }

    .ui_context_chip,
    .status_pill,
    .pill,
    .status-chip,
    .chip {
        white-space: normal;
        text-align: center;
    }
}
