/*
 * Erada professional responsive UX layer.
 *
 * Existing responsive source of truth:
 *   mobile: <= 767px
 *   tablet: 768px - 1180px
 *   desktop: >= 1181px (this file intentionally has no desktop overrides)
 */

.top-search-icon,
.responsive-validation-list,
.responsive-ux-only,
.ux-table-card-heading {
    display: none;
}

.responsive-skip-link {
    display: none;
}

@media screen and (max-width: 1180px) {
    :root {
        --responsive-touch-min: 44px;
        --responsive-safe-bottom: env(safe-area-inset-bottom, 0px);
        --responsive-safe-top: env(safe-area-inset-top, 0px);
        --responsive-focus-ring: 0 0 0 3px rgba(14, 165, 233, 0.3);
    }

    html,
    body {
        max-width: 100%;
        overflow-x: clip;
    }

    body.responsive-dialog-open {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .responsive-ux-only {
        display: initial;
    }

    .responsive-skip-link {
        position: fixed;
        z-index: 999;
        top: max(8px, var(--responsive-safe-top));
        right: 12px;
        display: block;
        padding: 10px 14px;
        border-radius: 10px;
        background: var(--brand);
        color: #fff;
        font-weight: 700;
        transform: translateY(-160%);
    }

    .responsive-skip-link:focus {
        transform: translateY(0);
    }

    .btn,
    button:not(.flatpickr-day),
    [role="button"],
    .icon-pill,
    summary,
    .tabs a,
    .tabs button,
    .series-tabs a,
    .series-tabs button,
    .patient-tabs a,
    .patient-tabs button {
        min-height: var(--responsive-touch-min);
    }

    .drawer-close {
        width: var(--responsive-touch-min);
        height: var(--responsive-touch-min);
        min-width: var(--responsive-touch-min);
        padding: 0;
        font-size: 1.45rem;
    }

    .btn:active,
    button:active,
    [role="button"]:active {
        transform: translateY(1px);
    }

    .btn:disabled,
    button:disabled,
    [aria-disabled="true"] {
        cursor: not-allowed;
        opacity: 0.58;
        box-shadow: none;
    }

    :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
        box-shadow: var(--responsive-focus-ring);
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea {
        min-height: var(--responsive-touch-min);
        max-width: 100%;
    }

    input[type="checkbox"],
    input[type="radio"] {
        min-width: 22px;
        min-height: 22px;
    }

    input[type="file"] {
        width: 100%;
        min-height: 48px;
        padding: 9px;
        overflow: hidden;
    }

    textarea {
        line-height: 1.65;
        resize: vertical;
    }

    label,
    fieldset,
    .form-grid > *,
    .toolbar > *,
    .toolbar-inline > * {
        min-width: 0;
    }

    .field-error {
        display: block;
        margin-top: 6px;
        color: #b91c1c;
        font-size: 0.875rem;
        line-height: 1.45;
    }

    :where(input, select, textarea)[aria-invalid="true"],
    :where(input, select, textarea):user-invalid {
        border-color: #dc2626;
        background: #fffafa;
    }

    .alert {
        overflow-wrap: anywhere;
    }

    .validation-summary {
        scroll-margin-top: 96px;
    }

    .responsive-validation-list {
        margin: 8px 0 0;
        padding-inline-start: 20px;
    }

    .responsive-validation-list li + li {
        margin-top: 4px;
    }

    .empty {
        min-height: 88px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        text-align: center;
        border-radius: 14px;
    }

    .search-dropdown {
        max-width: 100%;
        max-height: min(45dvh, 360px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .search-dropdown button,
    .quick-search-results button,
    .payments-patient-option {
        width: 100%;
        min-height: 52px;
        text-align: start;
        white-space: normal;
    }

    .table-wrap,
    .table-scroll-wrap,
    .patients-table-wrap {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    .table th,
    .table td,
    .data-table th,
    .data-table td {
        vertical-align: top;
    }

    .doc-actions,
    .patients-row-actions,
    .payments-actions,
    .tasks-row-actions,
    .profile-actions,
    .drawer-actions {
        gap: 10px;
    }

    .doc-actions .btn,
    .patients-row-actions .btn,
    .payments-actions .btn,
    .tasks-row-actions .btn {
        min-height: var(--responsive-touch-min);
    }

    .tabs,
    .series-tabs,
    .payments-tabs,
    .clinical-forms-registry-tabs {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .tabs > *,
    .series-tabs > *,
    .payments-tabs > *,
    .clinical-forms-registry-tabs > * {
        flex: 0 0 auto;
    }

    .modal-backdrop,
    .phrase-modal-overlay {
        overscroll-behavior: contain;
    }

    .modal,
    .phrase-modal {
        max-width: calc(100vw - 32px);
        max-height: calc(100dvh - 32px);
        overscroll-behavior: contain;
    }

    .modal .card-head,
    .phrase-modal > :first-child {
        scroll-margin-top: 12px;
    }

    [data-responsive-processing="true"] {
        cursor: wait;
    }

    [data-responsive-processing="true"] :where(button[type="submit"], input[type="submit"]) {
        pointer-events: none;
    }

    .ux-form-progress {
        min-height: 4px;
        border-radius: 999px;
        overflow: hidden;
        background: #dbeafe;
    }

    .ux-form-progress::after {
        content: "";
        display: block;
        width: 45%;
        height: 4px;
        background: var(--brand2);
        animation: responsive-progress 1s ease-in-out infinite alternate;
    }

    .history-item,
    .record-block,
    .series-block,
    .notice {
        overflow-wrap: anywhere;
    }

    :where([dir="auto"], .mixed-direction, [data-mixed-direction]) {
        unicode-bidi: plaintext;
        text-align: start;
    }

    :where([dir="ltr"], input[type="tel"], input[type="time"], input[inputmode="numeric"]) {
        unicode-bidi: isolate;
    }
}

@media screen and (min-width: 768px) and (max-width: 1180px) {
    .login-body {
        min-height: 100dvh;
        padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    }

    .login-page {
        width: min(760px, 100%);
        min-height: 0;
        border-radius: 24px;
    }

    .login-form-panel {
        min-height: min(620px, calc(100dvh - 40px));
    }

    .login-form-card {
        width: min(520px, 100%);
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid > .full,
    .form-grid > fieldset,
    .form-grid > .toolbar-inline,
    .form-grid > .alert {
        grid-column: 1 / -1;
    }

    .filter-bar,
    .payments-filter-grid,
    .commitment-follow-up-filter-grid,
    .past-due-filter-grid,
    .open-series-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .toolbar,
    .toolbar-inline {
        row-gap: 10px;
    }

    .toolbar :where(input, select),
    .filter-bar :where(input, select),
    .payments-filter-grid :where(input, select) {
        min-width: 150px;
    }

    .modal.narrow,
    .payment-modal,
    .quick-search-modal {
        width: min(760px, calc(100vw - 40px));
    }

    .table :where(.btn.small),
    .data-table :where(.btn.small) {
        min-height: var(--responsive-touch-min);
    }

    .clinical-form-studio-page .main,
    .employee-attendance-page .main {
        max-width: 1180px;
    }

    .medical-record-form > .toolbar-inline:not(.medical-record-tablet-action-bar) {
        display: none;
    }
}

@media screen and (max-width: 767px) {
    :root {
        --mobile-nav-height: 68px;
        --mobile-page-gutter: 12px;
        --mobile-header-height: 66px;
    }

    body {
        font-size: 15px;
        -webkit-text-size-adjust: 100%;
    }

    .login-body {
        display: block;
        min-height: 100dvh;
        padding: 0;
        background: linear-gradient(180deg, #e8eef8, #f8fafc 42%);
    }

    .login-page,
    .login-form-panel {
        width: 100%;
        min-height: 100dvh;
    }

    .login-form-panel {
        display: flex;
        align-items: center;
        padding: calc(22px + var(--responsive-safe-top)) 16px calc(22px + var(--responsive-safe-bottom));
    }

    .login-form-card {
        width: 100%;
        max-width: 480px;
        margin: 0 auto;
        padding: 26px 20px 22px;
        border: 1px solid rgba(226, 232, 240, 0.9);
        border-radius: 22px;
        box-shadow: 0 18px 48px rgba(15, 23, 42, 0.13);
    }

    .login-form-header {
        margin-bottom: 22px;
    }

    .login-form-header h2 {
        font-size: 1.35rem;
    }

    .login-field input {
        min-height: 52px;
    }

    .login-submit {
        min-height: 52px;
    }

    .main {
        min-width: 0;
        padding: var(--mobile-page-gutter);
        padding-bottom: calc(var(--mobile-nav-height) + var(--responsive-safe-bottom) + 20px);
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 42;
        min-height: var(--mobile-header-height);
        margin: calc(-1 * var(--mobile-page-gutter)) calc(-1 * var(--mobile-page-gutter)) 14px;
        padding: calc(10px + var(--responsive-safe-top)) var(--mobile-page-gutter) 10px;
        border: 0;
        border-bottom: 1px solid rgba(226, 232, 240, 0.92);
        border-radius: 0;
        box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(14px);
    }

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

    .topbar h1 {
        max-width: 52vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1.12rem;
        line-height: 1.25;
    }

    .topbar .eyebrow {
        margin-bottom: 2px;
        font-size: 0.68rem;
    }

    .top-actions {
        flex: 0 0 auto;
        gap: 6px;
    }

    .top-actions .user-chip {
        display: none;
    }

    .top-actions .pill {
        display: inline-flex;
        width: var(--responsive-touch-min);
        height: var(--responsive-touch-min);
        min-width: var(--responsive-touch-min);
        padding: 0;
        border-radius: 50%;
    }

    .top-search-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .top-search-icon {
        position: relative;
        display: block;
        width: 17px;
        height: 17px;
        border: 2px solid var(--brand);
        border-radius: 50%;
        color: transparent;
        font-size: 0;
    }

    .top-search-icon::after {
        content: "";
        position: absolute;
        width: 8px;
        height: 2px;
        right: -6px;
        bottom: -3px;
        border-radius: 999px;
        background: var(--brand);
        transform: rotate(45deg);
        transform-origin: center;
    }

    .top-actions .icon-pill {
        position: relative;
        display: inline-flex;
        align-items: center;
        width: var(--responsive-touch-min);
        height: var(--responsive-touch-min);
        min-width: var(--responsive-touch-min);
        padding: 0;
        justify-content: center;
        color: transparent;
        font-size: 0;
    }

    .top-actions .icon-pill::before {
        content: "";
        width: 16px;
        height: 15px;
        border: 2px solid var(--brand);
        border-bottom-width: 3px;
        border-radius: 9px 9px 5px 5px;
    }

    .top-actions .icon-pill::after {
        content: "";
        position: absolute;
        bottom: 9px;
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--brand);
    }

    .mobile-bottom-nav {
        min-height: calc(var(--mobile-nav-height) + var(--responsive-safe-bottom));
        height: auto;
        padding: 4px 4px var(--responsive-safe-bottom);
    }

    .mobile-nav-item {
        min-width: 0;
        min-height: 56px;
        padding: 5px 3px;
        border-radius: 12px;
        line-height: 1.15;
    }

    .mobile-nav-item.active:not(.mobile-nav-primary) {
        background: #eff6ff;
    }

    .mobile-nav-item.mobile-nav-primary {
        min-height: 54px;
        margin: 2px 4px;
    }

    .mobile-more-menu {
        bottom: calc(var(--mobile-nav-height) + var(--responsive-safe-bottom) + 4px);
        max-height: min(68dvh, 560px);
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 20px 20px 16px 16px;
        overscroll-behavior: contain;
    }

    .mobile-more-menu a,
    .mobile-more-menu button.mobile-more-logout {
        min-height: 48px;
    }

    .card {
        max-width: 100%;
        margin-bottom: 12px;
        padding: 14px;
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
    }

    .card.compact {
        padding: 12px;
    }

    .card-head {
        gap: 12px;
    }

    .card-head h2,
    .card h2 {
        overflow-wrap: anywhere;
    }

    .form-grid,
    .filter-bar,
    .payments-filter-grid,
    .commitment-follow-up-filter-grid,
    .past-due-filter-grid,
    .open-series-filter-grid,
    .auto-series-filter-grid,
    .clinical-forms-filters {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 14px;
    }

    .form-grid > *,
    .form-grid .full {
        grid-column: 1 !important;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px;
    }

    textarea {
        min-height: 128px;
    }

    .medical-record-form textarea[name="content"],
    .ia-form-sections textarea,
    .dynamic-clinical-form-page textarea {
        min-height: 180px;
    }

    .toolbar,
    .toolbar-inline,
    .profile-actions,
    .drawer-actions {
        width: 100%;
        align-items: stretch;
    }

    .toolbar > :where(input, select, .btn),
    .toolbar-inline > :where(.btn, button, a.btn),
    .profile-actions > .btn,
    .drawer-actions > .btn {
        width: 100%;
        max-width: none;
    }

    .toolbar-inline .inline,
    .toolbar-inline .inline-form,
    .doc-actions .inline,
    .doc-actions .inline-form {
        display: block;
        width: 100%;
    }

    .toolbar-inline .inline .btn,
    .toolbar-inline .inline-form .btn,
    .doc-actions .inline .btn,
    .doc-actions .inline-form .btn {
        width: 100%;
    }

    .tabs,
    .series-tabs,
    .payments-tabs,
    .clinical-forms-registry-tabs {
        flex-wrap: nowrap !important;
        margin: 12px 0;
        padding-bottom: 4px;
        scroll-snap-type: inline proximity;
    }

    .tabs > *,
    .series-tabs > *,
    .payments-tabs > *,
    .clinical-forms-registry-tabs > * {
        min-height: var(--responsive-touch-min);
        scroll-snap-align: start;
        white-space: nowrap;
    }

    .responsive-validation-list {
        display: block;
    }

    .validation-summary {
        position: relative;
        border: 1px solid #fecaca;
    }

    .modal-backdrop,
    .phrase-modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .modal,
    .modal.card,
    .quick-search-modal,
    .phrase-modal,
    .payment-modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100dvh - var(--responsive-safe-top)) !important;
        margin: 0 !important;
        padding: 18px 16px calc(18px + var(--responsive-safe-bottom)) !important;
        border-radius: 22px 22px 0 0 !important;
        overflow-x: hidden;
        overflow-y: auto;
        box-shadow: 0 -16px 42px rgba(15, 23, 42, 0.24);
    }

    .quick-search-modal {
        min-height: min(72dvh, 640px);
    }

    .quick-search-modal > input[type="search"] {
        min-height: 52px;
        font-size: 16px;
    }

    .quick-search-results {
        margin: 10px 0 0;
        padding: 0;
    }

    .phrase-modal-smart {
        height: min(88dvh, 760px);
    }

    .drawer:not(.calendar-drawer) {
        width: 100% !important;
        max-width: 100% !important;
    }

    .tablet-action-bar {
        position: sticky;
        z-index: 46;
        bottom: calc(var(--mobile-nav-height) + var(--responsive-safe-bottom) + 8px);
        display: flex;
        width: calc(100% + 4px);
        max-width: none;
        min-height: 68px;
        margin: 18px -2px 0;
        padding: 9px;
        gap: 8px;
        overflow-x: auto;
        justify-content: flex-start;
        border: 1px solid rgba(203, 213, 225, 0.96);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.97);
        box-shadow: 0 12px 34px rgba(15, 23, 42, 0.18);
        backdrop-filter: blur(14px);
        overscroll-behavior-inline: contain;
    }

    .tablet-action-bar > * {
        flex: 0 0 auto !important;
    }

    .tablet-action-bar .btn {
        min-width: 112px;
        min-height: 48px;
    }

    .medical-record-form > .toolbar-inline:not(.medical-record-tablet-action-bar) {
        display: none;
    }

    .clinical-form-editor-page .ia-form-actions {
        margin-bottom: 8px;
    }

    .patient-tablet-action-bar {
        display: flex;
    }

    .details-dl,
    .mini-dl,
    .history-item {
        grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
        gap: 8px 12px;
    }

    .history-item {
        padding: 12px;
    }

    .doc-upload-block,
    .upload-box,
    .doc-upload-form {
        max-width: 100%;
    }

    .preview-iframe {
        height: 62dvh;
    }

    .preview-thumb,
    .preview-full {
        width: auto;
        max-width: 100%;
        height: auto;
    }

    /*
     * Tables become semantic stacked cards only after responsive-ux.js adds
     * .ux-card-table and data-label attributes. Tables with dedicated mobile
     * presentations or genuinely tabular clinical measurements are excluded.
     */
    table.ux-card-table {
        display: block;
        width: 100%;
        border: 0;
        border-spacing: 0;
    }

    table.ux-card-table > thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    table.ux-card-table > tbody,
    table.ux-card-table > tbody > tr,
    table.ux-card-table > tbody > tr > td {
        display: block;
        width: 100%;
    }

    table.ux-card-table > tbody > tr {
        margin-bottom: 12px;
        padding: 7px 12px;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 15px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    }

    table.ux-card-table > tbody > tr > td {
        min-height: 36px;
        padding: 9px 0 !important;
        border: 0 !important;
        border-bottom: 1px solid #edf2f7 !important;
        border-radius: 0 !important;
        overflow-wrap: anywhere;
    }

    table.ux-card-table > tbody > tr > td:last-child {
        border-bottom: 0 !important;
    }

    table.ux-card-table > tbody > tr > td[data-label] {
        display: grid;
        grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
    }

    table.ux-card-table > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        line-height: 1.45;
    }

    table.ux-card-table > tbody > tr > td[colspan] {
        display: flex;
        min-height: 88px;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    table.ux-card-table > tbody > tr > td[colspan]::before {
        content: none;
    }

    table.ux-card-table .doc-actions,
    table.ux-card-table .patients-row-actions,
    table.ux-card-table .payments-actions,
    table.ux-card-table .tasks-row-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    table.ux-card-table .doc-actions > *,
    table.ux-card-table .patients-row-actions > *,
    table.ux-card-table .payments-actions > *,
    table.ux-card-table .tasks-row-actions > * {
        min-width: 0;
    }

    table.ux-card-table .doc-actions .btn,
    table.ux-card-table .patients-row-actions .btn,
    table.ux-card-table .payments-actions .btn,
    table.ux-card-table .tasks-row-actions .btn {
        width: 100%;
    }

    .ia-form-page,
    .dynamic-clinical-form-page,
    .clinical-form-editor-page {
        max-width: 100%;
    }

    .ia-form-top {
        position: sticky;
        top: calc(var(--mobile-header-height) - 1px);
        z-index: 30;
    }

    .ia-form-sections,
    .ia-section,
    .dynamic-form-section {
        min-width: 0;
    }

    .ia-treatment-card,
    .ia-summary-card,
    .ia-accordion {
        max-width: 100%;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 15px;
        background: #f8fafc;
        overflow: hidden;
    }

    .ia-card-actions,
    .ia-section-tools {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .ia-card-actions .btn,
    .ia-section-tools .btn {
        width: 100%;
        min-height: 46px;
    }

    .ia-card-actions .btn.danger,
    .ia-card-actions .danger-outline {
        grid-column: 1 / -1;
        margin-top: 4px;
    }

    .ia-accordion-head,
    .ia-section-toggle {
        min-height: 52px;
    }

    .ia-grid,
    .dynamic-field-grid,
    .dynamic-form-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .ia-form-actions {
        bottom: calc(var(--mobile-nav-height) + var(--responsive-safe-bottom) + 8px);
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
    }

    .dynamic-measurement-table,
    .dynamic-custom-table,
    .cva-eval-table-wrap {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .field-phrase-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .field-phrase-row .phrase-suggest-btn {
        width: 100%;
    }

    .patient-mobile-nav {
        position: sticky;
        top: calc(var(--mobile-header-height) + 4px);
        z-index: 28;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: rgba(245, 247, 251, 0.96);
        backdrop-filter: blur(12px);
    }

    .patients-mobile-card,
    .tasks-mobile-card,
    .calendar-appt-card,
    .medical-record-tablet-card {
        content-visibility: auto;
        contain-intrinsic-size: 1px 220px;
    }

    .patients-row-actions,
    .tasks-row-actions,
    .calendar-appt-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .patients-row-actions > *,
    .tasks-row-actions > *,
    .calendar-appt-actions > * {
        min-width: 0;
        width: 100%;
    }

    .calendar-toolbar .calendar-date-form {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr) 48px;
        grid-template-areas:
            "previous date next"
            "show show today";
        gap: 8px;
    }

    .calendar-date-form > :nth-child(1) {
        grid-area: previous;
    }

    .calendar-date-form > .calendar-date-picker-wrap {
        grid-area: date;
        min-width: 0;
    }

    .calendar-date-form > button[type="submit"] {
        grid-area: show;
    }

    .calendar-date-form > .calendar-today-btn {
        grid-area: today;
    }

    .calendar-date-form > :nth-child(5) {
        grid-area: next;
    }

    .calendar-view-label {
        width: 100%;
        text-align: center;
    }

    .calendar-view-btn {
        min-width: 0;
        padding-inline: 8px;
    }

    .calendar-list-panel,
    .calendar-therapist-panel {
        padding: 12px;
    }

    .calendar-appt-card {
        min-height: 148px;
    }

    .calendar-appt-actions .btn {
        min-height: 46px;
    }

    .flatpickr-calendar {
        max-width: calc(100vw - 24px);
    }

    .flatpickr-day {
        min-width: 40px;
        min-height: 40px;
        line-height: 40px;
    }

    .pagination {
        display: flex;
        max-width: 100%;
        padding: 2px;
        gap: 4px;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
    }

    .pagination .page-link,
    .pagination a,
    .pagination span {
        min-width: var(--responsive-touch-min);
        min-height: var(--responsive-touch-min);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .signature-worker-row,
    .clinical-documents-form,
    .account-fieldset,
    .role-perm-form,
    .settings-form-box {
        max-width: 100%;
        overflow: hidden;
    }

    .signature-worker-row img {
        max-width: 100% !important;
        height: auto;
    }

    .signature-worker-row .toolbar-inline {
        display: grid;
        grid-template-columns: 1fr;
    }

    .payments-kpi-grid,
    .payment-summary-grid,
    .attendance-summary-grid,
    .patient-cf-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .toast {
        right: 12px !important;
        bottom: calc(var(--mobile-nav-height) + var(--responsive-safe-bottom) + 12px) !important;
        left: 12px !important;
        width: auto;
        max-width: none;
        text-align: center;
    }
}

@media screen and (max-width: 430px) {
    .topbar h1 {
        max-width: 46vw;
    }

    .mobile-nav-item {
        font-size: 0.66rem;
    }

    .mobile-nav-item .mobile-nav-icon {
        font-size: 1.12rem;
    }

    .details-dl,
    .mini-dl,
    .history-item,
    table.ux-card-table > tbody > tr > td[data-label] {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    table.ux-card-table .doc-actions,
    table.ux-card-table .patients-row-actions,
    table.ux-card-table .payments-actions,
    table.ux-card-table .tasks-row-actions {
        grid-template-columns: 1fr;
    }

    .payments-kpi-grid,
    .payment-summary-grid,
    .attendance-summary-grid,
    .patient-cf-summary-grid,
    .ia-card-actions,
    .ia-section-tools {
        grid-template-columns: 1fr !important;
    }
}

@media screen and (max-width: 767px) and (orientation: landscape) {
    :root {
        --mobile-header-height: 58px;
    }

    .topbar {
        min-height: 58px;
    }

    .topbar .eyebrow {
        display: none;
    }

    .mobile-more-menu {
        max-height: calc(100dvh - var(--mobile-nav-height) - 20px);
    }

    .modal,
    .quick-search-modal,
    .phrase-modal {
        max-height: 100dvh !important;
    }

    .calendar-drawer,
    .calendar-page .drawer {
        height: 100dvh !important;
        border-radius: 0 !important;
    }
}

@media screen and (min-width: 768px) and (max-width: 1180px) and (orientation: landscape) and (max-height: 600px) {
    .main {
        padding: 10px 14px 18px;
    }

    .topbar {
        min-height: 58px;
        margin-bottom: 8px;
        padding: 9px 14px;
    }

    .topbar .eyebrow {
        display: none;
    }

    .tablet-primary-nav {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 5px;
        margin-bottom: 10px;
        padding: 5px;
    }

    .tablet-primary-nav-item {
        min-height: 46px;
        gap: 5px;
        padding: 6px 4px;
    }

    .tablet-primary-nav-item > strong {
        font-size: 0.78rem;
    }

    .calendar-toolbar.card.compact {
        padding: 10px 14px;
    }

    .calendar-toolbar .calendar-current-day {
        margin-bottom: 6px;
        padding-bottom: 6px;
    }

    .calendar-view-switcher {
        margin-top: 6px;
        padding-top: 6px;
    }
}

@media screen and (max-width: 1180px) and (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@keyframes responsive-progress {
    from {
        transform: translateX(-10%);
    }
    to {
        transform: translateX(125%);
    }
}
