html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans', Arial, sans-serif;
    background: #f7f8fa;
    color: #1f2937;
}

.auth-page {
    background: linear-gradient(135deg, #eef4ff 0%, #f7f8fa 100%);
}

.custom-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    box-shadow: 0 2px 8px #1a479820;
    z-index: 120;
    border-bottom: 1px solid #e7e7e7;
    display: flex;
    align-items: center;
}

.custom-topbar .topbar-link {
    display: inline-block;
    color: #1a4798;
    font-weight: 500;
    text-decoration: none;
    padding: 11px 22px 11px 12px;
    border-radius: 8px;
    transition: background 0.15s;
}

.custom-topbar .topbar-link.active,
.custom-topbar .topbar-link:hover {
    background: #e6eefb;
    color: #1a4798;
}

.main-content {
    padding: 35px;
    min-height: 100vh;
    margin-right: 400px;
    margin-top: 56px;
}

.custom-sidebar-right {
    position: fixed;
    right: 0;
    top: 56px;
    width: 400px;
    height: calc(100vh - 56px);
    background: #fff;
    box-shadow: -2px 0 8px #1a479820;
    z-index: 100;
    padding: 32px 24px 24px;
    border-left: 1px solid #e7e7e7;
    overflow-y: auto;
}

.sidebar-title {
    color: #1a4798;
    font-weight: 700;
    font-size: 1.25em;
}

.sidebar-card,
.content-card,
.page-header-card,
.auth-card {
    background: #fff;
    border: 1px solid #e8edf5;
    box-shadow: 0 8px 24px rgba(26, 71, 152, 0.08);
    border-radius: 18px;
}

.sidebar-card,
.content-card {
    padding: 24px;
}

.page-header-card {
    padding: 24px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-title {
    font-size: 1.9rem;
    font-weight: 700;
    color: #1a4798;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a4798;
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 560px;
    padding: 36px;
}

.auth-title {
    color: #1a4798;
    font-weight: 700;
}

.form-control,
.form-select {
    border-radius: 12px;
    border-color: #d6dfef;
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(26, 71, 152, 0.15);
    border-color: #1a4798;
}

.btn-primary {
    background: #1a4798;
    border-color: #1a4798;
    border-radius: 12px;
}

.btn-primary:hover,
.btn-primary:focus {
    background: #153c81;
    border-color: #153c81;
}

.btn-outline-primary {
    color: #1a4798;
    border-color: #1a4798;
    border-radius: 12px;
}

.btn-outline-primary:hover {
    background: #1a4798;
    border-color: #1a4798;
}

.text-truncate-cell {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 700;
}

.status-new {
    background: #e8f0fe;
    color: #1a4798;
}

.status-progress {
    background: #fff4db;
    color: #9a6700;
}

.status-done {
    background: #e7f7ec;
    color: #137333;
}

.status-cancelled {
    background: #fde8e8;
    color: #b42318;
}

.empty-state {
    text-align: center;
    padding: 36px 20px;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.form-card {
    max-width: 900px;
}

.request-description {
    white-space: pre-wrap;
    line-height: 1.6;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid #eef2f7;
}

.detail-row:last-child {
    border-bottom: none;
}

.table > :not(caption) > * > * {
    padding: 1rem 0.75rem;
}

.list-group-item:last-child {
    border-bottom: 0 !important;
}

code {
    color: #1a4798;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
}

.file-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    padding: 14px 16px;
    border: 1px solid #e8edf5;
    border-radius: 14px;
    background: #f9fbff;
}

.file-row:hover,
.file-row.active {
    border-color: #b8c8ea;
    background: #eef4ff;
}

.preview-card {
    min-height: 340px;
    border: 1px solid #e8edf5;
    border-radius: 16px;
    padding: 16px;
    background: #fbfcfe;
}

.preview-image {
    width: 100%;
    max-height: 700px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.preview-frame {
    width: 100%;
    height: 720px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
}

.handler-result {
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.5;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

@media (max-width: 900px) {
    .custom-sidebar-right {
        position: static;
        width: auto;
        height: auto;
        box-shadow: none;
        border-left: none;
        padding: 16px;
        margin: 72px 12px 0;
        border-radius: 18px;
    }

    .main-content {
        margin-right: 0;
        padding: 12px;
    }

    .page-header-card {
        flex-direction: column;
        align-items: stretch;
    }

    .preview-frame {
        height: 420px;
    }
}

.manager-inline-status-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.project-file-list {
    max-height: 520px;
}

.handler-picker {
    min-width: 280px;
}

.handler-card {
    border: 1px solid #e8edf5;
    border-radius: 16px;
    padding: 16px;
    background: #fbfcfe;
}

.handler-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: #1a4798;
}

.handler-file-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: 360px;
    overflow: auto;
}

.handler-file-grid.small-grid {
    max-height: 260px;
}

.handler-file-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #e3ebfa;
    background: #f7faff;
    cursor: pointer;
}

.handler-file-option input {
    margin-top: 3px;
}

.handler-file-option span {
    word-break: break-word;
}


.tool-block {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 1rem;
    background: #fafcff;
}

#handlerToolsModal .modal-body {
    background: #f7f8fa;
}

#handlerToolsModal .list-group-item {
    border-radius: 12px;
    margin-bottom: .5rem;
}

.handler-picker {
    min-width: 240px;
}


.tool-block .form-label { font-size: 0.92rem; }
.tool-block .list-group-item { background: #fff; }
.template-list .list-group-item, .dictionary-list .list-group-item { border-radius: 12px; margin-bottom: 8px; }
.template-search-input, .dict-search-input { background: #fbfcfe; }
.handler-result { white-space: pre-wrap; word-break: break-word; }

.order-info-card {
    border: 1px solid #dbe5f3;
    border-radius: 16px;
    padding: 1rem 1.1rem;
    background: #f8fbff;
}

.order-info-title {
    font-weight: 700;
    color: #1a4798;
    margin-bottom: 0.65rem;
}

.order-info-text {
    color: #2b3b55;
    white-space: pre-line;
    margin-bottom: 0.6rem;
}

.order-note-list,
.required-docs-list {
    padding-left: 1.2rem;
}

.order-note-list li,
.required-docs-list li {
    margin-bottom: 0.35rem;
    color: #33415c;
}

.form-hint-card {
    border: 1px dashed #c9d8ef;
    border-radius: 14px;
    padding: 1rem;
    background: #fbfcff;
}


.order-catalog-accordion .accordion-button { font-weight: 600; }
.order-catalog-accordion .accordion-button:not(.collapsed) { box-shadow: none; }
.order-catalog-accordion .content-card.border { box-shadow: none; border: 1px solid #e7e7e7 !important; }


.compact-stats-card {
    padding: 18px 22px;
}

.compact-stats-grid {
    align-items: stretch;
}

.mini-stat-card {
    min-width: 150px;
    padding: 12px 16px;
    border: 1px solid #e2e8f3;
    border-radius: 14px;
    background: #f8fbff;
}

.mini-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1a4798;
    line-height: 1.1;
}

.mini-stat-label {
    font-size: 0.85rem;
    color: #60708f;
    margin-top: 4px;
}

.compact-direction-list {
    display: flex;
    flex-direction: column;
}

.compact-direction-item {
    border-bottom: 1px solid #e8edf5;
}

.compact-direction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
}

.compact-direction-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: none;
    background: transparent;
    padding: 0;
    text-align: left;
    color: #1c2a43;
}

.compact-direction-toggle::after {
    content: '▾';
    font-size: 0.9rem;
    color: #7b8aa6;
    margin-left: auto;
    transition: transform .18s ease;
}

.compact-direction-toggle.collapsed::after {
    transform: rotate(-90deg);
}

.compact-direction-title {
    font-weight: 600;
}

.compact-direction-meta {
    color: #74839d;
    font-size: 0.9rem;
    white-space: nowrap;
}

.compact-direction-body {
    padding: 0 18px 16px 18px;
}

.compact-type-list {
    border: 1px solid #e8edf5;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
}

.compact-type-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid #eef2f7;
    background: #fff;
}

.compact-type-title-wrap {
    min-width: 0;
}

.compact-type-title {
    font-weight: 600;
    color: #1f2f4d;
}

.compact-type-subtitle {
    margin-top: 2px;
}

@media (max-width: 768px) {
    .compact-direction-header,
    .compact-type-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .compact-direction-toggle {
        width: 100%;
    }

    .mini-stat-card {
        min-width: 130px;
    }
}


.compact-direction-info,
.compact-type-body {
    border: 1px solid #e8edf5;
    border-radius: 14px;
    background: #f8fbff;
    padding: 14px 16px;
}

.compact-info-block {
    min-width: 0;
}

.compact-info-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: #60708f;
    margin-bottom: 8px;
}

.compact-info-text {
    color: #1f2f4d;
    white-space: pre-line;
}

.compact-info-empty {
    color: #7b8aa6;
    font-size: 0.92rem;
}

.compact-note-list {
    margin: 10px 0 0 0;
    padding-left: 18px;
    color: #31425f;
}

.compact-note-list li + li {
    margin-top: 6px;
}

.compact-type-item {
    border-bottom: 1px solid #eef2f7;
    background: #fff;
}

.compact-type-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
}

.compact-type-toggle {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0;
    text-align: left;
    display: flex;
    align-items: center;
    color: #1f2f4d;
}

.compact-type-toggle::after {
    content: '▾';
    font-size: 0.9rem;
    color: #7b8aa6;
    margin-left: auto;
    transition: transform .18s ease;
}

.compact-type-toggle.collapsed::after {
    transform: rotate(-90deg);
}

.compact-type-title-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.compact-type-body {
    margin: 0 14px 14px 14px;
}

@media (max-width: 768px) {
    .compact-type-header {
        align-items: flex-start;
        flex-direction: column;
    }
}


.order-main-card {
    max-width: 1180px;
}

.order-form-side-note {
    padding: 16px 18px;
    background: #f9fbff;
    border: 1px solid #e2eaf8;
    border-radius: 14px;
    color: #4b5563;
    line-height: 1.5;
}

.service-builder-card {
    max-width: 1180px;
}

.order-form-info-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.service-info-card {
    padding: 18px 20px;
    border-radius: 16px;
    border: 1px solid #e4ebf7;
    background: #fbfcff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.service-info-title {
    font-weight: 700;
    color: #1a4798;
    margin-bottom: 8px;
}

.service-info-text {
    white-space: pre-wrap;
    line-height: 1.6;
    color: #374151;
}

.required-docs-list {
    padding-left: 1.15rem;
}

.required-docs-list li + li {
    margin-top: 0.35rem;
}

@media (max-width: 900px) {
    .order-main-card,
    .service-builder-card {
        max-width: 100%;
    }
}


.order-file-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px 2px;
}

.chat-message {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px 14px;
    background: #f8fafc;
}

.chat-message-support {
    border-left: 4px solid #1a4798;
}

.chat-message-customer,
.chat-message-own {
    border-left: 4px solid #16a34a;
    background: #f6fff8;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.86rem;
    color: #64748b;
    margin-bottom: 6px;
}

.chat-text {
    white-space: pre-wrap;
    line-height: 1.55;
    color: #0f172a;
}

.chat-attachment {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #dbe4f0;
}

.chat-widget .chat-box {
    max-height: 420px;
}

.chat-preview-card {
    min-height: 220px;
}

.chat-message-active {
    box-shadow: 0 0 0 2px rgba(26, 71, 152, 0.15);
}

.bg-danger-subtle {
    background: #fef2f2;
}

.text-danger {
    color: #b91c1c !important;
}

.chat-preview-card,
.preview-card.chat-preview-card {
    max-height: 260px;
    overflow: hidden;
}
.chat-preview-card .preview-frame,
.chat-preview-card .preview-image {
    max-height: 200px;
    width: 100%;
    object-fit: contain;
}
.chat-hub-floating {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 640px;
    height: 520px;
    z-index: 1500;
    background: #fff;
    border: 1px solid #dfe7f5;
    border-radius: 18px;
    box-shadow: 0 18px 36px rgba(26, 71, 152, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-hub-floating.with-sidebar { right: 420px; }
.chat-hub-header { padding: 12px 16px; border-bottom: 1px solid #eef2f7; background: #f9fbff; }
.chat-hub-title { font-weight: 700; color: #1a4798; }
.chat-hub-subtitle { font-size: .85rem; color: #6b7280; }
.chat-hub-body { display:flex; min-height:0; flex:1; }
.chat-hub-list { width: 240px; border-right: 1px solid #eef2f7; overflow-y: auto; background: #fbfcfe; }
.chat-hub-item { width:100%; text-align:left; border:0; background:transparent; padding:12px 14px; border-bottom:1px solid #f1f4f9; }
.chat-hub-item.active { background:#eaf1fa; }
.chat-hub-item.has-unread { background:#fff8e8; }
.chat-hub-item.has-unread.active { background:#f9efcc; }
.chat-hub-item .smaller { font-size:.75rem; }
.chat-hub-item-title { white-space: normal; overflow-wrap: anywhere; }
.chat-hub-panel { display:flex; flex-direction:column; flex:1; min-width:0; }
.chat-hub-panel-header { padding:12px 16px; border-bottom:1px solid #eef2f7; font-weight:600; }
.chat-hub-messages { flex:1; min-height:0; overflow-y:auto; padding:12px 16px; background:#fff; }
.chat-hub-preview { border-top:1px solid #eef2f7; background:#f8fbff; height:190px; min-height:190px; max-height:190px; overflow:hidden; padding:10px 12px; }
.chat-hub-preview .preview-frame,
.chat-hub-preview .preview-image { width:100%; height:130px; max-height:130px; object-fit:contain; border:0; background:#fff; border-radius:10px; }
.chat-hub-preview-head { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:8px; }
.chat-hub-form { border-top:1px solid #eef2f7; padding:10px 12px; background:#fff; }
@media (max-width: 1400px) { .chat-hub-floating.with-sidebar { right: 24px; } }
@media (max-width: 900px) { .chat-hub-floating { left:12px; right:12px; width:auto; height:70vh; bottom:12px; } .chat-hub-body{flex-direction:column;} .chat-hub-list{width:100%; max-height:160px; border-right:0; border-bottom:1px solid #eef2f7;} .chat-hub-preview{height:150px; min-height:150px; max-height:150px;} }

/* === Sidebar messenger overrides === */
.workspace-sidebar-only {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.workspace-sidebar-only .sidebar-summary-card {
    flex: 0 0 auto;
}
.workspace-sidebar-only .sidebar-chat-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-header {
    padding: 12px 14px;
    border-bottom: 1px solid #eef2f7;
    background: #f9fbff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-list {
    width: 145px;
    min-width: 145px;
    max-width: 145px;
    border-right: 1px solid #eef2f7;
    overflow-y: auto;
    background: #fbfcfe;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-item {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #f1f4f9;
    background: transparent;
    padding: 10px 8px;
    text-align: left;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-item-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-item-title {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.25;
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc3545;
    flex: 0 0 auto;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-unread-badge {
    font-size: .7rem;
    line-height: 1;
    color: #dc3545;
    font-weight: 700;
    flex: 0 0 auto;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-item.has-unread {
    background: #fff8e8;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-item.active {
    background: #eaf1fa;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-panel {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-panel-header {
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f7;
    font-weight: 600;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    background: #fff;
}
.workspace-sidebar-only .sidebar-chat-card .chat-hub-form {
    border-top: 1px solid #eef2f7;
    padding: 10px 12px;
    background: #fff;
}
.workspace-sidebar-only .sidebar-chat-card.is-collapsed {
    flex: 0 0 auto;
}
.workspace-sidebar-only .sidebar-chat-card.is-collapsed .chat-hub-body {
    display: none;
}
.workspace-sidebar-only .sidebar-chat-card.is-collapsed .chat-hub-header {
    border-bottom: 0;
}
.workspace-sidebar-only .sidebar-chat-card.is-collapsed [data-chat-hub-toggle] {
    transform: rotate(-90deg);
}

/* disable old floating layout when sidebar messenger is used */
.chat-hub-floating {
    position: static !important;
    right: auto !important;
    bottom: auto !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}

@media (max-width: 900px) {
    .workspace-sidebar-only .sidebar-chat-card .chat-hub-body {
        flex-direction: column;
    }
    .workspace-sidebar-only .sidebar-chat-card .chat-hub-list {
        width: 100%;
        min-width: 0;
        max-width: none;
        border-right: 0;
        border-bottom: 1px solid #eef2f7;
        max-height: 120px;
    }
}

.status-catalog-list {
    border: 1px solid #e8edf5;
    border-radius: 14px;
    overflow: hidden;
}

.status-catalog-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px) minmax(170px, 230px) auto;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(28, 42, 67, 0.08);
}

.status-catalog-row.status-new {
    background: #e8f0fe;
    color: #1a4798;
}

.status-catalog-row.status-progress {
    background: #fff4db;
    color: #7a5200;
}

.status-catalog-row.status-done {
    background: #e7f7ec;
    color: #137333;
}

.status-catalog-row.status-cancelled {
    background: #fde8e8;
    color: #9f1c14;
}

.status-catalog-title {
    font-weight: 700;
    color: inherit;
}

.status-catalog-code {
    color: inherit;
    opacity: 0.75;
    margin-top: 2px;
}

.status-catalog-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.status-catalog-label {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: inherit;
    opacity: 0.72;
}

.status-catalog-value {
    font-weight: 600;
    color: inherit;
}

@media (max-width: 992px) {
    .status-catalog-row {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }
}

.order-total-preview {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.95rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 999px;
    background: #fff;
    color: #64748b;
    font-size: 0.95rem;
}

.order-total-preview strong,
.service-price-preview {
    color: #0f172a;
    font-weight: 700;
}

.service-price-preview {
    font-size: 1.2rem;
}

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

.access-password {
    display: inline-block;
    padding: 0.35rem 0.55rem;
    border-radius: 0.5rem;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #0f172a;
    font-size: 0.92rem;
}

.compact-empty-state {
    padding: 24px 16px;
}

.custom-topbar .topbar-link-with-badge {
    position: relative;
}

.nav-notification-badge {
    position: absolute;
    top: -8px;
    right: 4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    border: 2px solid #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.file-row-button {
    width: 100%;
    border: 1px solid #e8edf5;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.file-row-button:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.25);
    outline-offset: 2px;
}

.file-dropzone {
    border: 2px dashed rgba(13, 110, 253, 0.25);
    border-radius: 1rem;
    background: #f8fafc;
    padding: 1.1rem;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.file-dropzone:hover,
.file-dropzone:focus,
.file-dropzone.drag-over {
    border-color: rgba(13, 110, 253, 0.65);
    background: #eef6ff;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.08);
    outline: none;
}

.file-dropzone-title {
    font-weight: 700;
    color: #0f172a;
}

.selected-file-list {
    padding: 0.65rem 0.8rem;
    border-radius: 0.75rem;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #334155;
    font-size: 0.9rem;
}

/* Compact customer orders table */
.customer-orders-card {
    overflow: visible;
}

.customer-orders-tabs {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.customer-orders-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

.customer-orders-search-wrap {
    max-width: 620px;
    min-width: min(100%, 320px);
}

.customer-orders-table-wrap {
    min-height: 120px;
}

.customer-orders-table {
    font-size: .86rem;
    margin-bottom: 0;
}

.customer-orders-table th,
.customer-orders-table td {
    padding: .45rem .5rem;
    vertical-align: middle;
}

.customer-orders-table thead th {
    white-space: nowrap;
    font-size: .78rem;
    color: #5f6b7a;
    font-weight: 700;
    border-bottom-width: 1px;
}

.customer-orders-table tbody td {
    border-color: rgba(15, 23, 42, .07);
}

.customer-orders-date,
.customer-orders-name,
.customer-orders-service-title,
.customer-orders-direction {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-orders-name,
.customer-orders-service-title,
.customer-orders-direction {
    white-space: nowrap;
}

.customer-status-badge {
    font-size: .72rem;
    padding: .22rem .5rem;
}

.customer-orders-actions .btn {
    padding: .18rem .45rem;
    font-size: .78rem;
}

.column-filter-wrap {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    position: relative;
}

.column-filter-label {
    display: inline-block;
}

.column-filter {
    position: relative;
    display: inline-block;
}

.column-filter summary {
    list-style: none;
    cursor: pointer;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    background: rgba(59, 130, 246, .08);
    user-select: none;
}

.column-filter summary::-webkit-details-marker {
    display: none;
}

.column-filter[open] summary {
    background: rgba(59, 130, 246, .16);
}

.column-filter-menu {
    position: absolute;
    z-index: 30;
    right: 0;
    top: calc(100% + .35rem);
    min-width: 220px;
    max-height: 260px;
    overflow: auto;
    padding: .55rem;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: .75rem;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .14);
}

.column-filter-option {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .15rem;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
}

.column-filter-option-all {
    border-bottom: 1px solid rgba(15, 23, 42, .08);
    margin-bottom: .25rem;
    padding-bottom: .45rem;
}

.compact-empty-state {
    padding: 2rem 1rem;
}

@media (max-width: 1200px) {
    .customer-orders-table {
        font-size: .82rem;
    }
    .customer-orders-table th,
    .customer-orders-table td {
        padding: .38rem .42rem;
    }
    .customer-orders-date,
    .customer-orders-name,
    .customer-orders-service-title,
    .customer-orders-direction {
        max-width: 150px;
    }
}

@media (max-width: 768px) {
    .customer-orders-toolbar,
    .customer-orders-tabs {
        width: 100%;
    }
    .customer-orders-tabs .btn {
        flex: 1 1 auto;
    }
    .customer-orders-search-wrap {
        max-width: 100%;
    }
}

/* Unified compact order tables for all dashboards */
.role-orders-table {
    font-size: 0.82rem;
}
.role-orders-table th,
.role-orders-table td {
    padding: 0.38rem 0.45rem;
    vertical-align: middle;
}
.role-orders-table .form-select-sm,
.compact-inline-select {
    min-width: 120px;
    max-width: 170px;
    font-size: 0.78rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}
.compact-order-summary-card .customer-orders-table-wrap {
    margin: 0;
}
.compact-order-summary-card .table {
    margin-bottom: 0;
}
.chat-widget .chat-box {
    max-height: 420px;
}
@media (min-width: 1200px) {
    .role-orders-table th,
    .role-orders-table td {
        white-space: nowrap;
    }
    .role-orders-table .customer-orders-service-title,
    .role-orders-table .customer-orders-direction,
    .role-orders-table .customer-orders-name {
        max-width: 220px;
    }
}
@media (max-width: 1199px) {
    .role-orders-table .form-select-sm,
    .compact-inline-select {
        max-width: none;
    }
}

/* Small slide-in flash notifications */
.crm-toast-container {
    position: fixed;
    top: 74px;
    right: 22px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.crm-toast-message {
    min-width: 260px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 14px;
    background: #1a4798;
    color: #fff;
    box-shadow: 0 14px 34px rgba(26, 71, 152, 0.25);
    font-size: 0.95rem;
    font-weight: 500;
    transform: translateX(125%);
    opacity: 0;
    animation: crmToastSlide 3s ease-in-out forwards;
}
@keyframes crmToastSlide {
    0% { transform: translateX(125%); opacity: 0; }
    12% { transform: translateX(0); opacity: 1; }
    82% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(125%); opacity: 0; }
}
@media (max-width: 576px) {
    .crm-toast-container {
        top: 16px;
        right: 12px;
        left: 12px;
    }
    .crm-toast-message {
        width: 100%;
        max-width: none;
    }
}

/* Customer payment modal */
.payment-receipts-compact-list {
    display: grid;
    gap: 0.5rem;
}
.payment-receipt-compact-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    color: inherit;
    text-decoration: none;
    background: var(--bs-body-bg);
}
.payment-receipt-compact-item:hover {
    border-color: rgba(13, 110, 253, 0.45);
    background: rgba(13, 110, 253, 0.04);
}

/* Adaptive table filter menus and column sorting */
.column-filter summary {
    gap: 0.08rem;
    min-width: 1.35rem;
    width: auto;
    padding: 0 0.28rem;
}

.column-filter-sorted summary {
    background: rgba(59, 130, 246, .18);
    color: #1d4ed8;
}

.column-sort-indicator {
    min-width: 0;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
}

.column-filter-menu {
    position: fixed;
    right: auto;
    z-index: 3500;
    min-width: 220px;
    max-width: calc(100vw - 16px);
    max-height: min(420px, 62vh);
    overflow: auto;
    overscroll-behavior: contain;
}

.column-filter-menu-title {
    margin: 0.05rem 0 0.35rem;
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.column-filter-values-title {
    margin-top: 0.6rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(15, 23, 42, .08);
}

.column-sort-actions {
    display: grid;
    gap: 0.3rem;
}

.column-sort-button {
    width: 100%;
    padding: 0.38rem 0.5rem;
    border: 1px solid rgba(15, 23, 42, .11);
    border-radius: 0.5rem;
    background: #fff;
    color: #1f2937;
    text-align: left;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.column-sort-button:hover,
.column-sort-button:focus-visible {
    border-color: rgba(37, 99, 235, .45);
    background: #eff6ff;
    color: #1d4ed8;
    outline: none;
}

.column-sort-reset {
    color: #64748b;
}

.role-orders-table thead th:first-child .column-filter-wrap {
    max-width: 100%;
}

@media (max-width: 768px) {
    .column-filter-menu {
        max-height: 55vh;
    }
}

/* Catalog ordering and visible row actions */
.catalog-order-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex: 0 0 auto;
    flex-wrap: nowrap;
}

.catalog-order-actions form {
    margin: 0;
}

.catalog-move-button {
    width: 32px;
    min-width: 32px;
    padding-left: 0;
    padding-right: 0;
    font-weight: 700;
}

.status-catalog-row {
    grid-template-columns: minmax(180px, 1fr) minmax(145px, 190px) minmax(165px, 210px) minmax(145px, 190px) auto;
}

@media (max-width: 1100px) {
    .compact-direction-header,
    .compact-type-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .compact-direction-toggle,
    .compact-type-toggle {
        flex: 1 1 480px;
    }

    .catalog-order-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .catalog-order-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .status-catalog-row .catalog-order-actions {
        width: auto;
    }
}

/* Adaptive compact order tables: keep names readable and fit secondary fields. */
.order-table-adaptive {
    width: 100%;
    table-layout: auto;
}
.order-table-adaptive .orders-col-date {
    width: 86px;
    min-width: 78px;
}
.order-table-adaptive .orders-col-name,
.order-table-adaptive .customer-orders-name {
    width: 22%;
    min-width: 180px;
    max-width: none;
    white-space: normal !important;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
}
.order-table-adaptive .orders-col-number {
    width: 112px;
    min-width: 96px;
}
.order-table-adaptive .orders-col-customer {
    width: 128px;
    min-width: 112px;
    white-space: normal;
    overflow-wrap: anywhere;
}
.order-table-adaptive .orders-col-service {
    width: 18%;
    min-width: 135px;
}
.order-table-adaptive .orders-col-status {
    min-width: 128px;
}
.order-table-adaptive .orders-col-payment {
    width: 105px;
    min-width: 92px;
}
.order-table-adaptive .orders-col-amount {
    width: 92px;
    min-width: 82px;
}
.order-table-adaptive .orders-col-executor {
    width: 155px;
    min-width: 132px;
}
.order-table-adaptive .orders-col-actions {
    width: 1%;
    min-width: 112px;
}
.order-table-adaptive .customer-orders-service-title,
.order-table-adaptive .customer-orders-direction {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.executor-order-extra-info .request-description {
    min-height: 0;
}

@media (max-width: 1199px) {
    .order-table-adaptive .orders-col-name,
    .order-table-adaptive .customer-orders-name {
        min-width: 165px;
    }
    .order-table-adaptive .orders-col-service {
        min-width: 125px;
    }
}

@media (max-width: 767px) {
    .order-table-adaptive .orders-col-name,
    .order-table-adaptive .customer-orders-name {
        min-width: 155px;
    }
    .order-table-adaptive .orders-col-date {
        min-width: 76px;
    }
}

/* === Resizable workspace and chat columns === */
:root {
    --workspace-sidebar-width: 440px;
}

.main-content {
    margin-right: var(--workspace-sidebar-width);
}

.custom-sidebar-right {
    width: var(--workspace-sidebar-width);
    overflow-y: auto;
    overflow-x: hidden;
}

.workspace-sidebar-only {
    position: fixed;
}

.workspace-sidebar-resizer {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 12px;
    z-index: 4;
    cursor: ew-resize;
    touch-action: none;
    outline: none;
}

.workspace-sidebar-resizer::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background .15s ease, box-shadow .15s ease;
}

.workspace-sidebar-resizer:hover::after,
.workspace-sidebar-resizer:focus-visible::after,
.workspace-sidebar-resizer.is-dragging::after {
    background: #1a4798;
    box-shadow: 0 0 0 3px rgba(26, 71, 152, .12);
}

body.is-resizing-layout,
body.is-resizing-layout * {
    cursor: ew-resize !important;
    user-select: none !important;
}

.workspace-sidebar-only .sidebar-chat-card {
    --chat-list-width: 155px;
}

.workspace-sidebar-only .sidebar-chat-card .chat-hub-list {
    width: var(--chat-list-width);
    min-width: var(--chat-list-width);
    max-width: var(--chat-list-width);
}

.chat-hub-list-resizer {
    position: relative;
    flex: 0 0 9px;
    width: 9px;
    margin-left: -4px;
    margin-right: -4px;
    z-index: 3;
    cursor: col-resize;
    touch-action: none;
    outline: none;
}

.chat-hub-list-resizer::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #e2e8f0;
    transition: background .15s ease, width .15s ease;
}

.chat-hub-list-resizer:hover::after,
.chat-hub-list-resizer:focus-visible::after,
.chat-hub-list-resizer.is-dragging::after {
    width: 2px;
    background: #1a4798;
}

.workspace-sidebar-only .sidebar-chat-card .chat-hub-panel {
    container-type: inline-size;
    overflow: hidden;
}

.workspace-sidebar-only .sidebar-chat-card .chat-hub-form,
.workspace-sidebar-only .sidebar-chat-card .chat-hub-form textarea,
.workspace-sidebar-only .sidebar-chat-card .chat-hub-form .form-control {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.chat-hub-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.chat-hub-form-status {
    flex: 1 1 120px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.chat-hub-actions {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    flex-wrap: wrap;
}

.chat-hub-actions .btn {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
}

.chat-hub-send-button {
    flex: 0 0 auto;
}

@container (max-width: 270px) {
    .chat-hub-form-footer {
        align-items: stretch;
    }
    .chat-hub-form-status {
        flex-basis: 100%;
    }
    .chat-hub-actions {
        width: 100%;
        margin-left: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .chat-hub-attach-button {
        width: 100%;
    }
}

@container (max-width: 205px) {
    .chat-hub-actions {
        grid-template-columns: 1fr;
    }
    .chat-hub-actions .btn {
        width: 100%;
    }
}

@media (max-width: 900px) {
    :root {
        --workspace-sidebar-width: 100%;
    }
    .custom-sidebar-right {
        width: auto;
        overflow: hidden;
    }
    .main-content {
        margin-right: 0;
    }
    .workspace-sidebar-resizer,
    .chat-hub-list-resizer {
        display: none;
    }
    .workspace-sidebar-only .sidebar-chat-card .chat-hub-list {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
}

/* === Mobile Telegram-inspired app shell === */
.mobile-app-header,
.mobile-bottom-tabs {
    display: none;
}

@media (max-width: 900px) {
    html, body {
        min-height: 100%;
        background: #f3f6fb;
    }

    body {
        padding-bottom: calc(74px + env(safe-area-inset-bottom));
        overflow-x: hidden;
    }

    .custom-topbar {
        display: none !important;
    }

    .mobile-app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        z-index: 1250;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 0 14px;
        padding-top: env(safe-area-inset-top);
        background: rgba(255, 255, 255, 0.96);
        border-bottom: 1px solid rgba(26, 71, 152, 0.10);
        box-shadow: 0 8px 24px rgba(26, 71, 152, 0.08);
        backdrop-filter: blur(14px);
    }

    .mobile-app-title {
        min-width: 0;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: #1a4798;
        font-weight: 800;
        font-size: 1.05rem;
    }

    .mobile-app-logo {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #e6eefb;
        box-shadow: inset 0 0 0 1px rgba(26, 71, 152, 0.08);
    }

    .mobile-app-user {
        min-width: 0;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: #64748b;
        font-size: 0.82rem;
    }

    .mobile-app-username {
        max-width: 116px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-app-logout {
        width: 34px;
        height: 34px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid #d6dfef;
        background: #fff;
        color: #1a4798;
        font-weight: 800;
        text-decoration: none;
    }

    .mobile-bottom-tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1250;
        display: flex;
        align-items: stretch;
        gap: 4px;
        min-height: 64px;
        padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
        overflow-x: auto;
        overflow-y: hidden;
        background: rgba(255, 255, 255, 0.97);
        border-top: 1px solid rgba(26, 71, 152, 0.12);
        box-shadow: 0 -10px 28px rgba(26, 71, 152, 0.10);
        backdrop-filter: blur(16px);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .mobile-bottom-tabs::-webkit-scrollbar {
        display: none;
    }

    .mobile-tab {
        position: relative;
        min-width: 70px;
        flex: 1 0 70px;
        border: 0;
        border-radius: 18px;
        background: transparent;
        color: #64748b;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 6px 8px;
        line-height: 1.1;
        font: inherit;
        font-weight: 700;
        transition: background .15s ease, color .15s ease, transform .15s ease;
    }

    .mobile-tab:active {
        transform: scale(0.96);
    }

    .mobile-tab.active,
    .mobile-tab.is-active {
        background: #e6eefb;
        color: #1a4798;
    }

    .mobile-tab-icon {
        font-size: 1.12rem;
        line-height: 1;
    }

    .mobile-tab-label {
        max-width: 74px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.68rem;
    }

    .mobile-tab-badge {
        position: absolute;
        top: 3px;
        right: 13px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 999px;
        background: #dc2626;
        color: #fff;
        border: 2px solid #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.66rem;
        font-weight: 800;
        line-height: 1;
    }

    .main-content {
        margin: 0 !important;
        margin-top: 56px !important;
        padding: 12px 10px 18px !important;
        min-height: calc(100vh - 56px - 74px);
    }

    .auth-wrapper {
        padding: 16px;
    }

    .content-card,
    .page-header-card,
    .sidebar-card,
    .auth-card {
        border-radius: 18px;
        box-shadow: 0 8px 22px rgba(26, 71, 152, 0.08);
    }

    .content-card,
    .sidebar-card {
        padding: 14px;
    }

    .page-header-card {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .page-title {
        font-size: 1.45rem;
    }

    .section-title {
        font-size: 1.08rem;
    }

    .btn,
    .form-control,
    .form-select {
        min-height: 42px;
    }

    .btn-sm,
    .form-select-sm,
    .form-control-sm {
        min-height: 34px;
    }

    .table-responsive,
    .customer-orders-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .customer-orders-card,
    .content-card {
        overflow: visible;
    }

    .customer-orders-table,
    .role-orders-table {
        min-width: 760px;
    }

    .order-table-adaptive {
        min-width: 820px;
    }

    .customer-orders-toolbar {
        align-items: stretch;
    }

    .customer-orders-toolbar > *,
    .customer-orders-search-wrap,
    .team-search-form {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .column-filter-menu {
        max-width: calc(100vw - 20px);
        min-width: min(260px, calc(100vw - 20px));
    }

    .modal-dialog {
        margin: 12px;
    }

    .modal-content {
        border-radius: 20px;
    }

    body.mobile-chat-open {
        overflow: hidden;
    }

    body.mobile-chat-open .main-content {
        display: none;
    }

    .custom-sidebar-right.workspace-sidebar-only {
        display: none;
        position: fixed !important;
        top: 56px !important;
        right: 0 !important;
        bottom: calc(64px + env(safe-area-inset-bottom)) !important;
        left: 0 !important;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 10px !important;
        background: #f3f6fb;
        border: 0;
        box-shadow: none;
        z-index: 1180;
        overflow: hidden;
    }

    body.mobile-chat-open .custom-sidebar-right.workspace-sidebar-only {
        display: flex;
        flex-direction: column;
    }

    body.mobile-chat-open .mobile-chat-tab {
        background: #e6eefb;
        color: #1a4798;
    }

    .workspace-sidebar-only .sidebar-header,
    .workspace-sidebar-only .sidebar-summary-card {
        display: none !important;
    }

    .workspace-sidebar-only .sidebar-chat-card {
        flex: 1 1 auto;
        height: 100%;
        max-height: none;
        min-height: 0;
        border-radius: 20px;
        border: 1px solid rgba(26, 71, 152, 0.10);
        box-shadow: 0 10px 28px rgba(26, 71, 152, 0.10);
        overflow: hidden;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-header {
        min-height: 54px;
        padding: 10px 12px;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card [data-chat-hub-toggle] {
        width: 36px;
        height: 36px;
        border-radius: 12px;
        font-size: 0;
    }

    .workspace-sidebar-only .sidebar-chat-card [data-chat-hub-toggle]::before {
        content: '×';
        font-size: 1.35rem;
        line-height: 1;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-body {
        display: grid;
        grid-template-rows: minmax(108px, 28vh) minmax(0, 1fr);
        flex: 1 1 auto;
        min-height: 0;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-list {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: none !important;
        border-right: 0;
        border-bottom: 1px solid #eef2f7;
        overflow-y: auto;
        background: #fbfcfe;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-item {
        padding: 11px 12px;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-item-title {
        font-size: 0.88rem;
        -webkit-line-clamp: 2;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-list-resizer,
    .workspace-sidebar-resizer {
        display: none !important;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-panel {
        min-height: 0;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-panel-header {
        padding: 10px 12px;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-messages {
        padding: 10px 12px;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-form {
        padding: 10px 12px 12px;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-form textarea {
        min-height: 58px;
        max-height: 120px;
        border-radius: 16px;
    }

    .chat-hub-form-footer {
        align-items: stretch;
    }

    .chat-hub-actions {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
        margin-left: 0;
    }

    .chat-hub-actions .btn {
        width: 100%;
        min-height: 40px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .chat-message {
        border-radius: 16px;
        padding: 10px 12px;
    }

    .chat-meta {
        flex-wrap: wrap;
        gap: 4px 10px;
    }
}

@media (max-width: 390px) {
    .mobile-tab {
        min-width: 64px;
        flex-basis: 64px;
        padding-left: 6px;
        padding-right: 6px;
    }

    .mobile-tab-label {
        max-width: 64px;
        font-size: 0.64rem;
    }

    .mobile-app-username {
        max-width: 84px;
    }

    .chat-hub-actions {
        grid-template-columns: 1fr;
    }
}

/* === Mobile messenger tab and clickable order rows === */
.orders-clickable-row {
    cursor: pointer;
}
.orders-clickable-row:hover {
    background: #f8fbff;
}
.orders-clickable-row:focus-within {
    background: transparent;
}
.chat-hub-back-button {
    display: none;
    flex: 0 0 auto;
}
.chat-hub-panel-title {
    min-width: 0;
    display: block;
}

@media (max-width: 900px) {
    body.mobile-chat-open .custom-sidebar-right.workspace-sidebar-only {
        display: flex !important;
        flex-direction: column;
    }

    body.mobile-chat-open .custom-sidebar-right.workspace-sidebar-only .sidebar-chat-card {
        display: flex !important;
    }

    .workspace-sidebar-only .sidebar-chat-card.is-collapsed .chat-hub-body {
        display: block !important;
    }

    .workspace-sidebar-only .sidebar-chat-card {
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-header {
        min-height: 58px;
        padding: 12px 14px;
        border-bottom: 1px solid #eef2f7;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-title {
        font-size: 1.05rem;
        font-weight: 800;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-body {
        display: block !important;
        flex: 1 1 auto;
        min-height: 0;
        height: calc(100% - 58px);
        overflow: hidden;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-list {
        display: block;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        height: 100%;
        max-height: none !important;
        overflow-y: auto;
        border-right: 0;
        border-bottom: 0;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-item {
        padding: 14px 16px;
        min-height: 62px;
        border-bottom: 1px solid #eef2f7;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-item.active,
    .workspace-sidebar-only .sidebar-chat-card .chat-hub-item.has-unread.active {
        background: #eef5ff;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-item-title {
        font-size: .95rem;
        line-height: 1.25;
        -webkit-line-clamp: 2;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-panel {
        display: none;
        height: 100%;
        min-height: 0;
        background: #fff;
    }

    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open > .chat-hub-header {
        display: none !important;
    }

    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-body {
        height: 100%;
    }

    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-list {
        display: none !important;
    }

    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-panel {
        display: flex !important;
        flex-direction: column;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-panel-header {
        min-height: 58px;
        padding: 10px 12px;
        display: flex;
        align-items: center;
        gap: 10px;
        background: #fff;
        border-bottom: 1px solid #eef2f7;
    }

    .chat-hub-back-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 14px;
        font-size: 1.45rem;
        line-height: 1;
        padding: 0;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-panel-title {
        font-weight: 800;
        color: #153b7c;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-messages {
        flex: 1 1 auto;
        min-height: 0;
        padding: 12px;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-form {
        padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #eef2f7;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-form-footer {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-actions {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(104px, auto);
        gap: 8px;
        margin-left: 0;
    }

    .workspace-sidebar-only .sidebar-chat-card .chat-hub-actions .btn {
        width: 100%;
        min-width: 0;
        white-space: normal;
    }
}

@media (max-width: 390px) {
    .workspace-sidebar-only .sidebar-chat-card .chat-hub-actions {
        grid-template-columns: 1fr;
    }
}

/* === PWA notifications and fixed mobile chat composer === */
.notification-enable-btn.notifications-enabled,
.mobile-app-notify.notifications-enabled {
    border-color: rgba(31, 88, 181, .25);
    background: #eaf1fa;
    color: #1f58b5;
}
.mobile-app-notify,
.mobile-app-install {
    border: 1px solid rgba(31, 88, 181, .18);
    background: #fff;
    color: #1f58b5;
    border-radius: 12px;
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
}
.mobile-app-install {
    padding: 0 10px;
    font-size: .72rem;
    white-space: nowrap;
}
.chat-notification-badge {
    right: 10px;
}

@media (max-width: 900px) {
    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-panel {
        height: 100% !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }
    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-form {
        flex: 0 0 auto !important;
        margin-top: auto !important;
        padding: 8px 12px calc(10px + env(safe-area-inset-bottom)) !important;
        background: #fff !important;
        border-top: 1px solid #eef2f7 !important;
    }
    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-form textarea {
        display: block !important;
        width: 100% !important;
        min-height: 46px !important;
        max-height: 96px !important;
        margin: 0 0 8px !important;
        border-radius: 16px !important;
        resize: vertical;
    }
    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-form-footer {
        margin-top: 0 !important;
        gap: 6px !important;
    }
    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-actions {
        align-items: stretch !important;
    }
    .workspace-sidebar-only .sidebar-chat-card.mobile-chat-conversation-open .chat-hub-actions .btn {
        min-height: 38px !important;
    }
}
