/*
 * Mobile application layout.
 * Everything in this file is deliberately scoped to phone-sized screens so
 * desktop and tablet layouts keep their existing behaviour.
 */
@media (max-width: 760px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    body .sidebar {
        position: fixed;
        inset: auto 0 0 0;
        width: 100%;
        height: 72px;
        min-height: 72px;
        padding: 4px 6px max(4px, env(safe-area-inset-bottom));
        display: flex !important;
        align-items: stretch;
        gap: 2px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        border: 0;
        border-top: 1px solid rgba(206, 220, 240, 0.95);
        background: rgba(255, 255, 255, 0.97);
        box-shadow: 0 -8px 28px rgba(28, 55, 92, 0.12);
        z-index: 80;
        -webkit-overflow-scrolling: touch;
    }

    body .sidebar h2,
    body .sidebar #userPanel,
    body .sidebar .sidebar-user,
    body .sidebar .sidebar-section-title {
        display: none !important;
    }

    body .sidebar .sidebar-group {
        display: flex !important;
        flex: 0 0 auto;
        align-items: stretch;
        gap: 2px;
        margin: 0;
        padding: 0;
        border: 0;
    }

    body .sidebar .sidebar-link {
        flex: 0 0 72px;
        width: 72px;
        height: 62px;
        min-height: 62px !important;
        margin: 0 !important;
        padding: 5px 3px !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        border-radius: 12px !important;
        color: #617493;
        font-size: 10px;
        line-height: 1.1;
        text-align: center;
    }

    body .sidebar .sidebar-link.active {
        color: #1768eb;
        background: #eaf2ff;
    }

    body .sidebar .sidebar-link-icon,
    body .sidebar .sidebar-link-icon svg {
        width: 21px;
        height: 21px;
    }

    body .sidebar .sidebar-link-text {
        display: block;
        width: 100%;
        overflow: hidden;
        font-size: 10px;
        line-height: 1.15;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body .sidebar-submenu {
        position: fixed !important;
        inset: 0 0 72px 0 !important;
        width: 100% !important;
        height: auto !important;
        padding: 14px !important;
        overflow: auto !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: #fff !important;
        box-shadow: none !important;
        transform: translateY(12px) !important;
        opacity: 0 !important;
        pointer-events: none !important;
        z-index: 79 !important;
    }

    body .sidebar-submenu.show {
        display: block !important;
        transform: translateY(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    body .sidebar-submenu-body {
        height: auto !important;
        overflow: visible !important;
    }

    body .main,
    body.settings-panel-open .main {
        width: 100% !important;
        margin: 0 !important;
        padding: 14px 10px calc(92px + env(safe-area-inset-bottom)) !important;
        box-sizing: border-box;
    }

    .topbar {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin: 0 0 10px;
    }

    .topbar::before {
        order: 0;
        font-size: 23px;
    }

    .topbar-left {
        display: contents;
    }

    #search {
        order: 1;
        width: 100%;
        max-width: none;
        height: 44px;
    }

    .orders-actions {
        order: 2;
        width: 100%;
        max-width: 100%;
        gap: 8px;
        overflow-x: auto;
        overflow-y: visible;
        flex-wrap: nowrap !important;
        padding: 1px 1px 5px;
        -webkit-overflow-scrolling: touch;
    }

    .orders-create-btn,
    .orders-filter-btn,
    .orders-saved-filter-btn {
        flex: 0 0 auto;
        min-width: auto;
        height: 42px;
        padding-inline: 15px;
    }

    .orders-saved-filters {
        display: contents;
    }

    .topbar-right {
        order: 3;
        width: 100%;
        max-width: 100%;
        padding: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        overflow: visible;
    }

    .orders-top-metrics {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 0;
        justify-content: flex-start;
        gap: 8px;
        overflow-x: auto;
        padding: 1px 1px 6px;
        -webkit-overflow-scrolling: touch;
    }

    .orders-top-metric {
        flex: 0 0 152px;
        min-width: 152px;
        min-height: 68px;
        padding: 10px 12px;
        grid-template-columns: 36px 1fr;
        gap: 3px 10px;
    }

    .orders-top-metric svg {
        width: 36px;
        height: 36px;
        padding: 8px;
    }

    .orders-columns {
        flex: 0 0 auto;
    }

    .orders-columns-toggle {
        min-width: 50px;
        width: 50px;
        padding: 0 7px;
    }

    .orders-columns-panel {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: min(65vh, 520px);
        overflow: auto;
    }

    .orders-filter-panel {
        order: 4;
        width: 100%;
        padding: 12px;
    }

    .orders-filter-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .orders-filter-select-wrap,
    .orders-filter-select-chip,
    .orders-filter-chip {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .orders-filter-select-chip {
        justify-content: flex-start;
    }

    .orders-filter-select-caret {
        margin-left: auto;
    }

    .orders-filter-select-menu {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: 52vh;
        overflow: auto;
        z-index: 90;
    }

    .orders-shell,
    .orders-table-wrap {
        width: 100%;
        max-width: 100%;
    }

    .orders-table-wrap {
        margin-top: 8px;
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .orders-table-wrap table,
    .orders-table-wrap tbody {
        display: block;
        width: 100%;
    }

    .orders-table-wrap colgroup,
    .orders-table-wrap thead {
        display: none;
    }

    .orders-table-wrap tbody tr {
        position: relative;
        display: block;
        width: 100%;
        margin: 0 0 10px;
        padding: 13px 13px 10px;
        box-sizing: border-box;
        overflow: visible;
        border: 1px solid #dfe8f4;
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(36, 64, 102, 0.08);
    }

    .orders-table-wrap tbody tr.orders-row-selected {
        border-color: #7ca7fb;
        background: #f6f9ff;
    }

    .orders-table-wrap tbody td {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto;
        min-height: 0;
        max-height: none;
        padding: 7px 0;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
        border: 0;
        border-bottom: 1px solid #edf2f8;
        background: transparent;
        white-space: normal;
        text-align: right;
    }

    .orders-table-wrap tbody td:last-child {
        border-bottom: 0;
    }

    .orders-table-wrap tbody td[data-column-label]::before {
        content: attr(data-column-label);
        flex: 0 0 38%;
        color: #71829e;
        font-size: 11px;
        line-height: 1.35;
        font-weight: 700;
        text-align: left;
    }

    .orders-table-wrap .orders-cell-content {
        flex: 1 1 auto;
        min-width: 0;
        overflow: visible;
        text-overflow: initial;
        white-space: normal;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .orders-table-wrap td[data-column-id="number"] {
        padding: 0 42px 11px 0;
        align-items: center;
    }

    .orders-table-wrap td[data-column-id="number"]::before {
        content: "Заказ";
        font-size: 12px;
    }

    .orders-table-wrap td[data-column-id="number"] .orders-cell-content {
        text-align: right;
    }

    .orders-table-wrap .orders-order-number {
        font-size: 16px;
    }

    .orders-table-wrap .orders-order-meta {
        font-size: 11px;
    }

    .orders-table-wrap .orders-select-col {
        position: absolute;
        top: 11px;
        right: 12px;
        z-index: 2;
        width: 24px !important;
        padding: 0;
        border: 0;
    }

    .orders-table-wrap .orders-status-select {
        max-width: 100%;
    }

    .orders-status-menu {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: 58vh;
        overflow: auto;
        z-index: 90;
    }

    .orders-pagination {
        gap: 5px;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 4px;
    }

    .orders-bulkbar {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 80px;
        z-index: 70;
        padding: 8px;
        border: 1px solid #dbe6f6;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 12px 30px rgba(28, 55, 92, 0.2);
    }

    .repair-drawer {
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh;
        border: 0;
    }

    .drawer-shell,
    .drawer-shell.timeline-rail-collapsed {
        height: 100%;
        display: flex !important;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .drawer-main-shell {
        flex: 0 0 auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .drawer-header {
        position: sticky;
        top: 0;
        z-index: 12;
        padding: 10px 10px 8px;
    }

    .drawer-header-top,
    .drawer-header-actions,
    .drawer-header-side {
        max-width: 100%;
    }

    .drawer-header-actions {
        margin: 0 0 8px;
        flex-wrap: wrap;
    }

    .drawer-header-side {
        margin-left: 0;
        padding-top: 0;
    }

    .drawer-tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .drawer-tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .drawer-body {
        flex: 0 0 auto;
        padding: 10px;
        overflow: visible;
    }

    .drawer-grid,
    .drawer-responsibles-grid,
    .form-grid,
    .drawer-form-grid {
        grid-template-columns: 1fr !important;
    }

    .drawer-side-shell,
    .drawer-side-shell.collapsed {
        flex: 0 0 auto;
        min-height: 380px;
        padding: 0 10px 90px;
        overflow: visible;
    }

    .timeline-card,
    .drawer-side-shell.collapsed .timeline-card {
        height: 460px;
        min-height: 380px;
        padding: 10px;
        opacity: 1;
        pointer-events: auto;
        overflow: hidden;
    }

    .timeline-rail-toggle {
        display: none !important;
    }

    .timeline-switch {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .timeline-switch button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .timeline-compose-row {
        align-items: flex-end;
    }

    .timeline-compose textarea {
        min-width: 0;
    }

    .drawer-footer {
        position: sticky;
        bottom: 0;
        z-index: 13;
        padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.97);
        box-shadow: 0 -8px 24px rgba(28, 55, 92, 0.1);
    }

    .drawer-footer button {
        min-height: 42px;
    }

    /* Contacts */
    .clients-page {
        min-height: 0;
        padding: 0;
    }

    .clients-tabs {
        width: 100%;
        height: auto;
        gap: 18px;
        margin: 0 0 12px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .clients-tab {
        flex: 0 0 auto;
        min-height: 38px;
    }

    .clients-toolbar {
        gap: 8px;
        margin-bottom: 10px;
    }

    .clients-toolbar-left {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }

    .clients-toolbar-left > * {
        flex: 0 0 auto;
    }

    .clients-create-btn,
    .clients-filter-btn,
    .clients-action-btn,
    .clients-icon-btn {
        min-height: 40px;
        border-radius: 8px;
    }

    .clients-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .clients-type-filter-menu,
    .clients-manager-filter-menu,
    .clients-birthday-filter-menu,
    .clients-age-filter-menu,
    .clients-tag-filter-menu,
    .clients-columns-panel {
        position: fixed;
        inset: auto 10px 82px 10px;
        width: auto;
        max-height: 55vh;
        overflow: auto;
        z-index: 90;
    }

    .clients-table-shell {
        border: 1px solid #e1e8f2;
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .clients-footer {
        overflow-x: auto;
    }

    .client-form-header,
    .client-form-footer,
    .client-form-body {
        padding-inline: 12px;
    }

    .client-form-discount-controls {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Tasks */
    .tasks-page {
        padding: 0 0 18px;
    }

    .tasks-tabs {
        overflow-x: auto;
        white-space: nowrap;
    }

    .tasks-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .tasks-create-btn {
        width: 100%;
        min-height: 42px;
    }

    .tasks-segmented {
        display: flex;
        width: 100%;
        overflow-x: auto;
        grid-template-columns: none;
        -webkit-overflow-scrolling: touch;
    }

    .tasks-segmented button {
        flex: 0 0 auto;
        min-height: 40px;
        white-space: nowrap;
    }

    .tasks-select,
    .tasks-select select,
    .tasks-notif-btn {
        width: 100%;
        box-sizing: border-box;
    }

    .tasks-select {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        align-items: center;
    }

    .tasks-select select,
    .tasks-notif-btn {
        min-height: 40px;
    }

    .task-create-drawer,
    .task-view-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
    }

    /* Leads */
    .leads-head-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .leads-head-actions > button {
        min-width: 0;
        min-height: 42px;
    }

    .leads-filters {
        gap: 9px;
    }

    .leads-table-wrap {
        width: 100%;
        overflow-x: auto;
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .lead-create-modal,
    .lead-edit-modal {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100dvh - 20px);
        overflow: auto;
    }

    /* VK chats: list and dialog behave as two phone screens. */
    .vk-chats-page {
        height: calc(100dvh - 100px);
        min-height: 520px;
        gap: 10px;
        overflow: hidden;
    }

    .vk-chats-head {
        gap: 9px;
    }

    .vk-chats-head p {
        display: none;
    }

    .vk-chats-head nav {
        width: 100%;
        box-sizing: border-box;
    }

    .vk-chats-head nav button {
        flex: 1 1 50%;
        min-width: 0;
        padding-inline: 8px;
    }

    .vk-chat-layout {
        display: block;
        min-height: 0;
        height: 100%;
        border-radius: 12px;
    }

    .vk-chat-list {
        width: 100%;
        height: 100%;
        max-height: none;
        overflow-y: auto;
        border: 0;
    }

    .vk-chat-dialog {
        display: none;
        width: 100%;
        height: 100%;
        min-height: 0;
        position: relative;
    }

    .vk-chat-layout.mobile-dialog-open .vk-chat-list {
        display: none;
    }

    .vk-chat-layout.mobile-dialog-open .vk-chat-dialog {
        display: flex;
    }

    .vk-chat-mobile-back {
        position: absolute;
        top: 9px;
        left: 8px;
        z-index: 3;
        height: 38px;
        padding: 0 10px;
        border: 0;
        border-radius: 19px;
        background: #eaf2ff;
        color: #2769b2;
        font-size: 24px;
        line-height: 1;
    }

    .vk-chat-mobile-back span {
        font-size: 12px;
        font-weight: 700;
        vertical-align: 3px;
    }

    .vk-chat-dialog header {
        gap: 7px;
        padding: 10px 10px 10px 78px;
    }

    .vk-chat-dialog header > div {
        flex: 1 1 auto;
        min-width: 0;
    }

    .vk-chat-dialog header strong,
    .vk-chat-dialog header small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .vk-chat-switch {
        flex: 0 0 auto;
        max-width: 82px;
        font-size: 10px;
    }

    .vk-chat-messages {
        padding: 8px;
    }

    .vk-message,
    .vk-message.out {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 8px;
        padding: 9px 3px;
    }

    .vk-message-avatar {
        width: 34px;
        height: 34px;
        font-size: 11px;
    }

    .vk-message-line {
        gap: 6px;
    }

    .vk-message-line strong {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .vk-message-text {
        font-size: 14px;
    }

    .vk-chat-compose {
        gap: 7px;
        padding: 8px;
    }

    .vk-chat-compose textarea {
        min-width: 0;
        max-height: 110px;
    }

    .vk-chat-compose button {
        padding-inline: 12px;
    }

    .vk-bot-settings {
        padding-bottom: 90px;
    }

    .vk-bot-card {
        padding: 14px 12px;
    }

    .vk-bot-connection,
    .vk-copy-field,
    .vk-doc-list a {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .vk-settings-save {
        position: sticky;
        bottom: 0;
        z-index: 5;
        padding: 9px 0;
        background: rgba(255, 255, 255, 0.96);
    }

    .vk-settings-save button {
        width: 100%;
        min-height: 44px;
    }

    /* Finance */
    .finance-page {
        margin: 0;
        padding: 0 0 20px;
        gap: 12px;
    }

    .finance-page-header h1 {
        font-size: 23px;
    }

    .finance-tabs {
        width: 100%;
        gap: 20px;
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .finance-tab {
        flex: 0 0 auto;
        min-height: 42px;
    }

    .finance-workspace {
        display: block;
    }

    .finance-cashboxes {
        margin-bottom: 12px;
    }

    .finance-cashboxes-list {
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        padding: 1px 1px 7px;
        -webkit-overflow-scrolling: touch;
    }

    .finance-cashbox-item {
        flex: 0 0 220px;
    }

    .finance-add-cashbox-btn {
        min-height: 42px;
    }

    .finance-panel {
        min-width: 0;
    }

    .finance-panel-head,
    .finance-panel-actions-row,
    .finance-filters-row {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .finance-panel-actions-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .finance-panel-actions-row > button:last-child {
        grid-column: 1 / -1;
    }

    .finance-green-btn,
    .finance-red-btn,
    .finance-ghost-btn,
    .finance-filter-btn {
        min-height: 42px;
        justify-content: center;
    }

    .finance-period-filter,
    .finance-period-filter > button {
        width: 100%;
    }

    .finance-period-dropdown,
    .finance-cashbox-menu {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: 55vh;
        overflow: auto;
        z-index: 95;
    }

    .finance-table-wrap,
    .finance-payroll-table-wrap {
        width: 100%;
        overflow-x: auto;
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .finance-table {
        min-width: 760px;
    }

    .finance-account-drawer,
    .finance-transaction-drawer,
    .finance-payment-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh;
    }

    .finance-account-head {
        position: sticky;
        top: 0;
        z-index: 3;
        padding-inline: 12px;
    }

    .finance-account-body {
        padding-inline: 12px;
    }

    .finance-account-footer {
        position: sticky;
        bottom: 0;
        z-index: 3;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        background: #fff;
    }

    .finance-account-footer-right,
    .finance-account-submit {
        width: 100%;
    }

    /* Inventory */
    .inventory-page {
        margin: 0;
        padding: 0 0 20px;
        gap: 12px;
    }

    .inventory-page-header {
        gap: 8px;
        flex-direction: column;
    }

    .inventory-page-header h1 {
        font-size: 23px;
    }

    .inventory-page-header p {
        margin-top: 5px;
        font-size: 13px;
    }

    .inventory-tabs {
        width: 100%;
        gap: 20px;
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .inventory-tab {
        flex: 0 0 auto;
        min-height: 42px;
    }

    .inventory-workspace,
    .inventory-page.inventory-page-has-drawer-no .inventory-workspace {
        display: block;
    }

    .inventory-toolbar,
    .inventory-toolbar-filters {
        gap: 8px;
    }

    .inventory-toolbar button,
    .inventory-select-card {
        min-height: 42px;
    }

    .inventory-category-menu,
    .inventory-actions-menu,
    .inventory-columns-menu {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: 58vh;
        overflow: auto;
        z-index: 95;
    }

    .inventory-table-wrap,
    .inventory-receipt-table-wrap,
    .inventory-import-preview-table,
    .inventory-import-sheet-wrap {
        width: 100%;
        overflow-x: auto;
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .inventory-drawer,
    .inventory-item-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
        min-height: 100dvh;
        margin: 0;
        border-radius: 0;
    }

    .inventory-receipt-page {
        padding: 0 0 20px;
    }

    .inventory-receipt-copy {
        font-size: 13px;
        line-height: 1.45;
    }

    .inventory-receipt-toolbar,
    .inventory-receipt-toolbar-left,
    .inventory-receipt-toolbar-right,
    .inventory-receipt-detail-head,
    .inventory-receipt-detail-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .inventory-receipt-toolbar button,
    .inventory-receipt-detail-actions button {
        width: 100%;
        min-height: 42px;
    }

    .inventory-receipt-divider {
        display: none;
    }

    .inventory-receipt-filter-menu,
    .inventory-receipt-actions-menu,
    .inventory-receipt-settings-menu {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: 55vh;
        overflow: auto;
        z-index: 95;
    }

    .inventory-receipt-composer,
    .inventory-import-root,
    .inventory-import-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
        min-height: 100dvh;
    }

    /* Reports */
    .reports-page {
        margin: 0;
    }

    .reports-tabs {
        width: 100%;
        gap: 20px;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .reports-tab,
    .reports-tab-menu {
        flex: 0 0 auto;
    }

    .reports-tab {
        min-height: 42px;
    }

    .reports-activity {
        padding: 10px 0 20px;
    }

    .reports-filters {
        align-items: stretch;
        flex-direction: column;
    }

    .reports-filter,
    .reports-apply-btn {
        width: 100%;
        min-height: 42px;
        height: auto;
        box-sizing: border-box;
    }

    .reports-filter select {
        flex: 1 1 auto;
        max-width: none;
        min-width: 0;
    }

    .reports-period-menu,
    .reports-event-menu,
    .reports-tab-dropdown {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: 58vh;
        overflow: auto;
        z-index: 95;
    }

    .reports-table-wrap,
    .reports-status-wrap {
        width: 100%;
        overflow-x: auto;
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .reports-table,
    .reports-ad-table,
    .reports-status-table {
        min-width: 720px;
    }

    .reports-cashflow-summary {
        gap: 8px;
    }

    /* Settings and administrative editors */
    #pageContent > .settings-page,
    #pageContent > .settings-section,
    #pageContent > .settings-content {
        width: 100%;
        max-width: 100%;
        padding-inline: 0;
        box-sizing: border-box;
    }

    .general-settings-card,
    .finance-payment-settings-card,
    .finance-category-settings-card,
    .finance-price-settings-card {
        padding: 14px 12px;
        border-radius: 12px;
    }

    .settings-toolbar,
    .settings-actions,
    .settings-header {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .settings-toolbar button,
    .settings-actions button {
        min-height: 42px;
    }

    .directories-layout,
    .directory-workspace,
    .employees-layout,
    .roles-layout,
    .order-card-builder {
        grid-template-columns: 1fr !important;
    }

    .directories-table-wrap,
    .employees-table-wrap,
    .roles-table-wrap,
    .custom-fields-table-wrap,
    .documents-table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .crm-modal {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
        overflow: auto;
    }

    /* Metrics */
    .metrics-page {
        min-height: 0;
        margin: 0;
        padding: 0 0 20px;
    }

    .metrics-head {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 14px;
    }

    .metrics-title h2 {
        font-size: 23px;
    }

    .metrics-title p {
        font-size: 13px;
    }

    .metrics-actions {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: 1fr;
    }

    .metrics-select,
    .metrics-date-input {
        width: 100%;
        min-width: 0;
        height: 44px;
        box-sizing: border-box;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .metrics-card {
        min-height: 108px;
        grid-template-columns: 46px 1fr;
        gap: 13px;
        padding: 16px;
    }

    .metrics-card-icon {
        width: 46px;
        height: 46px;
    }

    .metrics-panel {
        padding: 14px 12px;
        overflow-x: auto;
    }

    /* Sales */
    .sales-page {
        min-height: 0;
        padding: 0 0 20px;
    }

    .sales-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .sales-toolbar-left,
    .sales-toolbar-right {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .sales-toolbar-left > *,
    .sales-toolbar-right > * {
        flex: 0 0 auto;
    }

    .sales-primary-btn,
    .sales-period-btn,
    .sales-action-btn,
    .sales-icon-btn {
        min-height: 42px;
        height: 42px;
        border-radius: 8px;
    }

    .sales-toolbar-divider {
        display: none;
    }

    .sales-period-dropdown,
    .sales-actions-menu,
    .sales-columns-menu {
        position: fixed !important;
        inset: auto 10px 82px 10px !important;
        width: auto !important;
        max-height: 58vh;
        overflow: auto;
        z-index: 95;
    }

    .sales-table-wrap {
        width: 100%;
        overflow-x: auto;
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .sales-drawer,
    .sales-create-drawer,
    .sales-detail-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh;
    }

    .sales-form-grid,
    .sales-summary-grid {
        grid-template-columns: 1fr !important;
    }

    /* Payment calendar */
    .cal-page {
        padding: 0 0 20px;
    }

    .cal-topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 14px;
    }

    .cal-title {
        font-size: 23px;
    }

    .cal-topbar .cal-btn {
        width: 100%;
        min-height: 42px;
    }

    .cal-summary-grid {
        display: flex;
        gap: 8px;
        margin-bottom: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cal-summary-card {
        flex: 0 0 240px;
        min-height: 86px;
        padding: 14px;
    }

    .cal-workspace {
        display: block;
    }

    .cal-sidebar-panel {
        display: flex;
        flex-direction: row;
        gap: 8px;
        margin-bottom: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cal-side-card {
        flex: 0 0 260px;
        padding: 14px;
    }

    .cal-view-tabs {
        width: 100%;
        overflow-x: auto;
    }

    .cal-calendar-card,
    .cal-table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cal-month-grid {
        min-width: 620px;
    }

    .cal-table {
        min-width: 760px;
    }

    .cal-modal,
    .cal-drawer {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100dvh - 20px);
        overflow: auto;
    }

    /* Help */
    .help-page {
        width: 100%;
        max-width: 100%;
        gap: 12px;
    }

    .help-page-header,
    .help-guide-head {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .help-page-header h1 {
        font-size: 23px;
    }

    .help-tabs {
        width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
    }

    .help-tabs button {
        flex: 0 0 auto;
    }

    .help-search {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .help-guide-grid {
        grid-template-columns: 1fr;
    }

    /* Employees and roles */
    .employees-page,
    .roles-page,
    .employee-settings-page {
        width: 100%;
        max-width: 100%;
    }

    .employees-toolbar,
    .roles-toolbar,
    .employee-settings-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .employees-toolbar button,
    .roles-toolbar button,
    .employee-settings-toolbar button {
        min-height: 42px;
    }

    .employees-table,
    .roles-table,
    .permissions-table {
        min-width: 720px;
    }

    .role-permissions-layout,
    .employee-form-grid,
    .employee-access-grid,
    .payroll-settings-grid {
        grid-template-columns: 1fr !important;
    }

    .employee-drawer,
    .role-drawer,
    .permissions-drawer {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh;
    }

    .invite-link-box {
        align-items: stretch;
        flex-direction: column;
    }

    .invite-copy-btn,
    .invite-send-btn {
        width: 100%;
        min-height: 42px;
    }

    /* Directories */
    .directories-page,
    .directories-screen {
        width: 100%;
        max-width: 100%;
    }

    .directories-grid,
    .directory-cards,
    .directory-form-grid,
    .catalog-settings-grid {
        grid-template-columns: 1fr !important;
    }

    .directory-toolbar,
    .directories-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .directory-toolbar button,
    .directories-toolbar button {
        min-height: 42px;
    }

    .directory-table,
    .directories-table {
        min-width: 720px;
    }

    /* Documents */
    .document-settings-screen {
        width: 100%;
        max-width: 100%;
    }

    .document-settings-topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .document-settings-layout {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .document-template-tabs {
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .document-template-tab,
    .document-template-add {
        flex: 0 0 190px;
        min-height: 42px;
    }

    .document-template-editor-head {
        grid-template-columns: 1fr;
    }

    .document-variables-panel {
        max-height: 320px;
        overflow: auto;
    }

    .document-editor-toolbar,
    .word-editor-toolbar {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .document-editor-toolbar > *,
    .word-editor-toolbar > * {
        flex: 0 0 auto;
    }

    .word-editor-page,
    .document-editor-page {
        min-width: 680px;
    }
}

@media (min-width: 761px) {
    .vk-chat-mobile-back {
        display: none;
    }

    .mobile-profile-link {
        display: none !important;
    }

    .mobile-profile-logout {
        display: none !important;
    }
}

.profile-password-field {
    position: relative;
    display: block;
}

.profile-password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    min-height: 30px;
    padding: 4px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #2878d0;
    font-size: 12px;
    font-weight: 700;
    transform: translateY(-50%);
    cursor: pointer;
}

.profile-password-toggle:hover {
    background: #eef6ff;
}
