:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #172033;
    --muted: #647084;
    --line: #d9e0ea;
    --line-strong: #c6d0dd;
    --brand: #176b87;
    --brand-dark: #0d4d63;
    --brand-soft: #e8eef5;
    --success: #166534;
    --success-bg: #e7f7ed;
    --warning: #92400e;
    --warning-bg: #fff4d6;
    --danger: #b42318;
    --danger-bg: #fff0ee;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.client-filters {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(150px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.client-filters label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-weight: 700;
}

.client-filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.client-table-wrap {
    overflow-x: auto;
}

.clients-load-more {
    padding: 18px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 980px) {
    .client-filters {
        grid-template-columns: 1fr 1fr;
    }

    .client-filter-search,
    .client-filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .client-filters {
        grid-template-columns: 1fr;
    }

    .client-filter-search,
    .client-filter-actions {
        grid-column: auto;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
}

.pwa-install-button {
    position: fixed;
    z-index: 120;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px;
    background: #102a43;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .25);
}

.pwa-install-button[hidden] {
    display: none;
}

@media (display-mode: standalone) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .topbar {
        padding-top: max(13px, env(safe-area-inset-top));
        padding-right: max(22px, env(safe-area-inset-right));
        padding-left: max(22px, env(safe-area-inset-left));
    }
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.help-dot:focus {
    outline: 3px solid rgba(23, 107, 135, .24);
    outline-offset: 2px;
}

.button-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}

.button-link:hover {
    background: var(--brand-dark);
    color: #fff;
    text-decoration: none;
}

.button-link.secondary {
    border: 1px solid #9aa4b2;
    background: #e5e9ef;
    color: var(--text);
}

.button-link.secondary:hover {
    background: #d8dee8;
    color: var(--text);
}

.button-link.telegram-chats-button {
    background: #9f1239;
}

.button-link.telegram-chats-button:hover {
    background: #881337;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 13px 22px;
    background: #102a43;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand {
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
    white-space: nowrap;
}

.topbar nav {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.topbar nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 8px;
    color: #dbeafe;
    line-height: 1.2;
    transition: background .16s ease, color .16s ease;
}

.topbar nav a:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
    text-decoration: none;
}

.topbar nav a img {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.topbar-notification-center {
    position: relative;
    flex: 0 0 auto;
    margin-left: auto;
}

.topbar-push-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: 0;
    min-height: 34px;
    padding: 6px 11px;
    border-color: #be123c;
    background: #be123c;
    color: #fff;
    font-size: 13px;
    line-height: 1.2;
}

.notification-count-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.notification-count-badge[hidden] {
    display: none;
}

.notification-center-panel {
    position: absolute;
    z-index: 130;
    top: calc(100% + 10px);
    right: 0;
    width: min(420px, calc(100vw - 32px));
    max-height: min(620px, calc(100vh - 92px));
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .24);
}

.notification-center-panel[hidden] {
    display: none;
}

.notification-center-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.notification-center-head strong {
    font-size: 17px;
}

.notification-panel-close {
    width: 32px;
    min-height: 32px;
    padding: 0;
    border-color: var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
}

.notification-panel-close:hover {
    background: var(--panel-soft);
    color: var(--text);
}

.notification-push-status {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 13px;
}

.notification-push-status.is-ok {
    border-color: #bbf7d0;
    background: var(--success-bg);
    color: var(--success);
}

.notification-push-status.is-error {
    border-color: #fecaca;
    background: var(--danger-bg);
    color: var(--danger);
}

.notification-category-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.notification-category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #111;
    font-weight: 700;
    transition: none;
}

.notification-category-item:visited {
    color: #111;
}

.notification-category-item:hover,
.notification-category-item:focus,
.notification-category-item:active {
    background: var(--brand-soft);
    color: #111;
    text-decoration: none;
}

.notification-category-item strong {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 12px;
}

.notification-center-list {
    display: grid;
    gap: 8px;
}

.notification-center-item {
    display: grid;
    gap: 3px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    text-align: left;
    text-decoration: none;
}

.notification-center-item.is-support {
    border-left-color: #b45309;
}

.notification-center-item:hover {
    background: var(--panel-soft);
    color: var(--text);
    text-decoration: none;
}

.notification-center-item span,
.notification-center-item time {
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.notification-center-item .notification-group-count {
    justify-self: start;
    margin-top: 3px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.4;
}

.notification-center-item.is-support .notification-group-count {
    background: #fff7ed;
    color: #9a3412;
}

.notification-center-empty {
    padding: 18px 10px;
    color: var(--muted);
    text-align: center;
}

.notification-read-all {
    width: 100%;
    margin-top: 10px;
}

.topbar-push-button:hover {
    border-color: #9f1239;
    background: #9f1239;
}

.topbar-push-button.is-enabled {
    border-color: #94a3b8;
    background: #64748b;
}

.topbar-push-button.is-enabled:hover {
    border-color: #64748b;
    background: #475569;
}

.topbar-push-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
}

.topbar-push-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.admin-menu-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 11px;
    border-color: rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.admin-menu-toggle:hover {
    background: rgba(255, 255, 255, .14);
}

.admin-menu-toggle img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.page {
    width: min(1180px, calc(100% - 32px));
    min-width: 0;
    margin: 24px auto 56px;
}

.admin-notification-stack {
    position: fixed;
    z-index: 90;
    right: 18px;
    top: 78px;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
}

.admin-notification-toast {
    display: grid;
    gap: 4px;
    padding: 13px 14px;
    border: 1px solid #bfdbfe;
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    box-shadow: 0 14px 38px rgba(15, 23, 42, .16);
    text-decoration: none;
    transition: opacity .2s ease, transform .2s ease;
}

.admin-notification-toast:hover {
    color: var(--text);
    text-decoration: none;
    transform: translateY(-1px);
}

.admin-notification-toast strong {
    color: var(--brand-dark);
}

.admin-notification-toast span {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.admin-notification-toast.is-hiding {
    opacity: 0;
    transform: translateY(-4px);
}

h1 {
    margin: 0 0 18px;
    font-size: 26px;
    letter-spacing: 0;
    line-height: 1.2;
}

h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.panel,
table {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 20px;
    margin-bottom: 18px;
    min-width: 0;
}

.not-found-panel {
    max-width: 620px;
    margin: 64px auto;
    text-align: center;
}

.not-found-code {
    margin-bottom: 10px;
    color: var(--brand);
    font-size: 64px;
    font-weight: 800;
    line-height: 1;
}

.not-found-panel h2 {
    margin-bottom: 8px;
}

.not-found-panel p {
    margin: 0 0 20px;
    color: var(--muted);
}

.not-found-panel .button-link {
    width: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 700;
    background: #eef3f8;
}

tbody tr:hover td {
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: 0;
}

input,
textarea,
select,
button {
    width: 100%;
    min-width: 0;
    border-radius: 6px;
    border: 1px solid var(--line);
    padding: 10px 11px;
    font: inherit;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease;
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--line-strong);
}

textarea {
    resize: vertical;
}

button {
    width: auto;
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

button:hover {
    background: var(--brand-dark);
}

button.secondary {
    border-color: #9aa4b2;
    background: #e5e9ef;
    color: var(--text);
}

button.secondary:hover {
    background: #d8dee8;
}

label {
    display: grid;
    gap: 6px;
    min-width: 0;
    margin-bottom: 14px;
    color: var(--muted);
    font-weight: 700;
}

.auth-form {
    max-width: 420px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

.notice,
.error {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.notice {
    background: #e7f8ef;
    color: #14532d;
}

.error {
    background: #fef3f2;
    color: var(--danger);
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.stats div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.stats strong {
    display: block;
    font-size: 30px;
}

.stats span {
    color: var(--muted);
}

.payment-stats strong {
    font-size: 24px;
}

.payment-filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.payment-filters label {
    margin-bottom: 0;
}

.payment-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.secondary-link {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
}

.secondary-link:hover {
    background: var(--panel-soft);
    color: var(--text);
}

.payment-status-summary {
    margin-bottom: 14px;
}

.payment-status-summary span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
}

.analytics-filters {
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.analytics-chart-panel {
    overflow: hidden;
}

.analytics-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.analytics-chart-head h2 {
    margin-bottom: 2px;
}

.analytics-chart-head p {
    margin: 0;
}

.analytics-chart-head strong {
    color: var(--brand-dark);
    font-size: 24px;
    line-height: 1.2;
    text-align: right;
}

.analytics-chart-wrap {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
}

.analytics-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.analytics-table-wrap table {
    min-width: 1120px;
}

.tariff-channel-row td:first-child {
    border-left: 4px solid transparent;
}

.tariff-channel-row.tariff-channel-telegram td {
    background: rgba(37, 99, 235, .045);
}

.tariff-channel-row.tariff-channel-telegram td:first-child {
    border-left-color: #2563eb;
}

.tariff-channel-row.tariff-channel-external td {
    background: rgba(234, 88, 12, .055);
}

.tariff-channel-row.tariff-channel-external td:first-child {
    border-left-color: #ea580c;
}

.tariff-channel-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
}

.tariff-channel-badge-telegram {
    border-color: #93c5fd;
    background: #dbeafe;
    color: #1d4ed8;
}

.tariff-channel-badge-external {
    border-color: #fdba74;
    background: #ffedd5;
    color: #c2410c;
}

.tariff-channel-badge-other {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #475569;
}

.analytics-chart-svg {
    display: block;
    width: 100%;
    min-width: 720px;
    height: auto;
}

.analytics-axis {
    stroke: #94a3b8;
    stroke-width: 1.4;
}

.analytics-grid-line {
    stroke: #e2e8f0;
    stroke-width: 1;
}

.analytics-axis-label {
    fill: #647084;
    font: 12px/1.2 Arial, Helvetica, sans-serif;
}

.analytics-bar {
    fill: var(--brand);
    transition: opacity .16s ease;
}

.analytics-bar:hover {
    opacity: .78;
}

.analytics-line {
    fill: none;
    stroke: var(--brand);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.analytics-line-point {
    fill: #fff;
    stroke: var(--brand-dark);
    stroke-width: 2.4;
}

.analytics-line-point:hover {
    fill: var(--brand-soft);
}

.payment-raw summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 700;
}

.payment-raw pre {
    max-width: 420px;
    max-height: 260px;
    margin: 8px 0 0;
    padding: 10px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.health-item {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.health-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 20px;
}

.health-item span {
    color: var(--muted);
}

.health-item.is-ok {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.health-item.is-ok strong {
    color: #166534;
}

.health-item.is-bad {
    border-color: #fecaca;
    background: #fef2f2;
}

.health-item.is-bad strong {
    color: var(--danger);
}

.toolbar,
.actions,
.row-form,
.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.toolbar {
    margin-bottom: 14px;
}

.toolbar a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    transition: background .16s ease, border-color .16s ease, color .16s ease;
}

.toolbar a:hover,
.toolbar a.is-active {
    border-color: #b8c6d8;
    background: var(--brand-soft);
    color: var(--brand-dark);
    text-decoration: none;
}

.toolbar a.toolbar-primary {
    margin-left: auto;
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.toolbar a.toolbar-primary:hover {
    border-color: var(--brand-dark);
    background: var(--brand-dark);
    color: #fff;
}

.toolbar a.toolbar-group-spaced {
    margin-left: 24px;
}

.nav-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    min-height: 20px;
    padding: 2px 6px;
    margin-left: 4px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.nav-count-danger {
    background: #dc2626;
}

.nav-count-muted {
    background: #64748b;
}

.mobile-filter {
    display: none;
    margin-bottom: 14px;
}

.mobile-filter-action {
    display: none;
    margin: -6px 0 14px;
}

.mobile-filter-action a {
    color: var(--brand);
    font-weight: 700;
}

.mobile-filter label {
    margin-bottom: 0;
}

.mobile-filter select {
    margin-top: 6px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.message {
    border: 1px solid var(--line);
    border-left: 4px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    background: #fff;
    margin-bottom: 10px;
}

.message div {
    color: var(--muted);
    font-size: 13px;
}

.message.client {
    border-left-color: #f59e0b;
    background: #fff;
}

.message.specialist,
.message.admin {
    border-left-color: var(--brand);
    background: #f8fafc;
}

.message p {
    margin: 8px 0 0;
    overflow-wrap: anywhere;
}

.message-image-link {
    display: inline-block;
    max-width: min(420px, 100%);
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}

.message-image-link:hover {
    border-color: var(--line-strong);
}

.message-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
}

.message-audio {
    display: block;
    width: min(520px, 100%);
    margin-top: 10px;
}

.message-document-link {
    display: inline-flex;
    max-width: 100%;
    margin-top: 10px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.message-document-link:hover {
    border-color: var(--line-strong);
    background: #eef3f8;
    text-decoration: none;
}

.file-field {
    margin-top: 12px;
}

.small {
    width: 76px;
}

.muted {
    color: var(--muted);
}

.client-modal-row td {
    height: 0;
    padding: 0;
    border: 0;
}

.admin-modal {
    position: fixed;
    z-index: 120;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(15, 23, 42, .48);
}

.admin-modal[hidden] {
    display: none;
}

.admin-modal-dialog {
    width: min(820px, 100%);
    max-height: calc(100vh - 44px);
    overflow: auto;
    padding: 18px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 22px 70px rgba(15, 23, 42, .32);
}

.client-modal-dialog {
    width: min(1080px, 100%);
}

.admin-modal-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.admin-modal-head h2 {
    margin-bottom: 2px;
}

.admin-modal-head p {
    margin: 0;
    color: var(--muted);
}

.publish-modal-dialog {
    width: min(920px, 100%);
}

.publication-editor-form {
    display: grid;
    gap: 12px;
}

.publication-editor-field {
    display: grid;
    gap: 6px;
}

.publication-editor-field textarea {
    min-height: 360px;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.45;
    resize: vertical;
}

.client-settings-grid {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 16px;
}

.client-settings-section {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.client-settings-section h3 {
    margin: 0 0 12px;
    font-size: 17px;
}

.client-history-section {
    margin-top: 16px;
}

.client-history-title,
.client-history-head,
.client-history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.client-history-title h3 {
    margin: 0;
}

.client-history-actions,
.ticket-summary-actions,
.table-action-links,
.chat-history-pagination {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-sort-buttons {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.chat-sort-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 21px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
}

.chat-sort-button:hover {
    background: #e5e9ef;
    color: var(--text);
    text-decoration: none;
}

.chat-sort-button.is-active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .16);
}

.table-action-links {
    align-items: flex-start;
    flex-direction: column;
}

.chat-history-filters {
    display: grid;
    grid-template-columns: minmax(180px, .45fr) minmax(240px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.chat-history-filters label {
    margin: 0;
}

.chat-history-filters .form-actions {
    margin: 0;
}

.client-chat-compression-option {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 2px 0 8px;
    color: var(--text);
}

.client-chat-compression-option input {
    width: auto;
    margin: 0;
}

.chat-transcript {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.chat-message {
    width: min(760px, 88%);
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.chat-message-in {
    justify-self: start;
    border-bottom-left-radius: 3px;
}

.chat-message-out {
    justify-self: end;
    border-color: #bfdbfe;
    border-bottom-right-radius: 3px;
    background: #eff6ff;
}

.chat-message-callback {
    width: min(620px, 82%);
    justify-self: center;
    border-style: dashed;
    border-radius: 999px;
    background: #f8fafc;
    text-align: center;
}

.chat-message-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    color: var(--muted);
    font-size: 12px;
}

.chat-message-meta strong {
    color: var(--text);
    font-size: 13px;
}

.chat-message-meta time {
    margin-left: auto;
}

.chat-message p {
    margin: 8px 0 0;
    overflow-wrap: anywhere;
    white-space: normal;
}

.chat-history-image-link {
    display: block;
    margin-top: 10px;
}

.chat-history-image-link .message-image {
    max-height: 460px;
}

.chat-delivery-failed,
.chat-message-error {
    color: #b91c1c;
}

.chat-message-error {
    margin-top: 8px;
    font-size: 12px;
}

.chat-history-pagination {
    justify-content: space-between;
    margin-top: 16px;
}

.client-history-list {
    display: grid;
    gap: 0;
    margin-top: 14px;
}

.client-history-item {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    padding-bottom: 16px;
}

.client-history-item:not(:last-child)::before {
    content: '';
    position: absolute;
    top: 12px;
    bottom: 0;
    left: 5px;
    width: 2px;
    background: var(--line);
}

.client-history-marker {
    position: relative;
    z-index: 1;
    width: 12px;
    height: 12px;
    margin-top: 4px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: var(--brand);
    box-shadow: 0 0 0 1px var(--line);
}

.client-history-payment .client-history-marker {
    background: #16a34a;
}

.client-history-answer .client-history-marker {
    background: #2563eb;
}

.client-history-subscription .client-history-marker {
    background: #7c3aed;
}

.client-history-content {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.client-history-head {
    align-items: flex-start;
}

.client-history-head time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
}

.client-history-content p {
    margin: 6px 0;
    color: var(--muted);
}

.client-history-meta {
    justify-content: flex-start;
    font-size: 13px;
}

.client-history-status {
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
}

.one-column-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.one-column-form label {
    margin-bottom: 0;
}

.client-subscription-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.client-subscription-summary div {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.client-subscription-summary span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.client-subscription-summary strong {
    display: block;
    overflow-wrap: anywhere;
}

.client-date-card,
.client-days-card {
    position: relative;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 28px;
    min-height: 28px;
    padding: 0;
    border-color: #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: var(--brand);
    line-height: 1;
}

.icon-button:hover {
    background: #edf6f9;
    color: var(--brand-dark);
}

.payment-mark-paid-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.client-date-card .icon-button,
.client-days-card .icon-button {
    position: absolute;
    top: 8px;
    right: 8px;
}

.client-date-form,
.client-days-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 10px;
}

.client-days-form {
    grid-template-columns: auto minmax(58px, 1fr) auto auto;
}

.client-date-form[hidden],
.client-days-form[hidden] {
    display: none;
}

.client-actions-stack {
    display: grid;
    gap: 12px;
}

.client-actions-stack label {
    width: auto;
    margin-bottom: 0;
}

.client-actions-stack .inline-form {
    justify-content: flex-start;
    gap: 8px;
}

.client-actions-stack .inline-form label {
    display: inline-grid;
    grid-template-columns: max-content 76px;
    align-items: center;
    gap: 8px;
}

.client-actions-stack .inline-form .small {
    width: 76px;
}

.client-actions-stack .inline-form .icon-button {
    width: 36px;
    min-height: 36px;
    border-radius: 6px;
    font-size: 18px;
}

.settings-page-form {
    display: grid;
    gap: 16px;
}

.settings-group {
    margin-bottom: 0;
}

.settings-group-head {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.settings-group-head h2 {
    margin: 0 0 5px;
}

.settings-group-head p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.settings-save-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    justify-content: flex-end;
    padding: 12px 0 4px;
    background: linear-gradient(to top, var(--bg) 72%, rgba(245, 247, 251, 0));
}

.settings-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 18px;
    min-width: 0;
    overflow: visible;
}

.settings-form button {
    align-self: end;
}

.settings-form.one-column-form {
    grid-template-columns: 1fr;
}

.setting-field {
    margin-bottom: 0;
    min-width: 0;
}

.setting-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text);
}

.settings-file-field {
    display: grid;
    gap: 8px;
}

.settings-file-preview {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.settings-file-preview img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
}

.settings-file-preview span {
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.help-wrap {
    position: relative;
    display: inline-flex;
}

.help-dot {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #93a4b8;
    background: #fff;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    cursor: help;
    line-height: 1;
    user-select: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.help-dot:hover,
.help-dot:focus {
    border-color: var(--brand);
    background: #e8f4f8;
    color: var(--brand-dark);
}

.help-tooltip {
    position: absolute;
    z-index: 10;
    left: 0;
    bottom: calc(100% + 10px);
    width: 300px;
    max-width: calc(100vw - 64px);
    padding: 10px 12px;
    border-radius: 8px;
    background: #102a43;
    color: #fff;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .22);
    transform: translateY(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}

.help-tooltip::after {
    content: "";
    position: absolute;
    left: 12px;
    top: 100%;
    border: 6px solid transparent;
    border-top-color: #102a43;
}

.help-wrap:hover .help-tooltip,
.help-dot:focus + .help-tooltip {
    opacity: 1;
    transform: translateY(0);
}

.settings-form .setting-field:nth-child(even) .help-tooltip {
    right: 0;
    left: auto;
}

.settings-form .setting-field:nth-child(even) .help-tooltip::after {
    right: 12px;
    left: auto;
}

.field-help {
    color: var(--muted);
    font-weight: 400;
}

.message-character-counter {
    margin: -4px 0 12px;
    color: var(--muted);
    font-size: 0.875rem;
    text-align: right;
}

.message-character-counter.limit-exceeded {
    color: var(--danger, #b42318);
    font-weight: 600;
}

textarea.input-limit-exceeded {
    border-color: var(--danger, #b42318);
}

.copy-row {
    margin-top: 12px;
    min-width: 0;
}

.copy-row label {
    margin-bottom: 0;
    min-width: 0;
}

input[readonly] {
    background: var(--panel-soft);
    color: #334155;
    text-overflow: ellipsis;
}

.checkbox-input {
    width: auto;
}

.debug-box {
    max-width: 100%;
    overflow-x: auto;
    padding: 12px;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font: 13px/1.45 Consolas, monospace;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #eef4f2;
    color: #405552;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.ticket-statuses {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.publication-status-badge {
    border-color: #bbf7d0;
    background: var(--success-bg);
    color: var(--success);
}

.ticket-publication-action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
}

.ticket-publication-note {
    color: var(--success);
    font-size: 13px;
    font-weight: 800;
}

.access-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.access-claim {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.access-write {
    border-color: #bbf7d0;
    background: var(--success-bg);
    color: var(--success);
}

.access-readonly {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #475569;
}

.access-admin {
    border-color: #d8b4fe;
    background: #faf5ff;
    color: #6b21a8;
}

.status-new {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.status-in_progress {
    border-color: #fed7aa;
    background: var(--warning-bg);
    color: var(--warning);
}

.status-answered {
    border-color: #bbf7d0;
    background: var(--success-bg);
    color: var(--success);
}

.status-paid {
    border-color: #bbf7d0;
    background: var(--success-bg);
    color: var(--success);
}

.status-active {
    border-color: #bbf7d0;
    background: var(--success-bg);
    color: var(--success);
}

.status-expired,
.status-blocked,
.status-none {
    border-color: #fecaca;
    background: var(--danger-bg);
    color: var(--danger);
}

.status-pending {
    border-color: #fed7aa;
    background: var(--warning-bg);
    color: var(--warning);
}

.status-failed,
.status-refunded {
    border-color: #fecaca;
    background: var(--danger-bg);
    color: var(--danger);
}

.status-needs_clarification {
    border-color: #fde68a;
    background: #fff8db;
    color: #854d0e;
}

.status-closed {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #475569;
}

.status-inactive {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #475569;
}

.status-rejected {
    border-color: #fecaca;
    background: var(--danger-bg);
    color: var(--danger);
}

.empty-state {
    padding: 22px;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--muted);
    text-align: center;
}

.telegram-link-warning-panel {
    border-color: #7f1d1d;
    background: #fff7f7;
}

.telegram-link-warning {
    display: grid;
    justify-items: center;
    gap: 10px;
    border-color: #991b1b;
    background: #7f1d1d;
    color: #fff;
    font-weight: 700;
}

.telegram-link-warning strong {
    color: #fff;
    font-size: 16px;
}

.telegram-link-warning a {
    color: #ffe4e6;
    font-weight: 800;
    text-decoration: underline;
}

.copy-command-button {
    max-width: 100%;
    border-color: rgba(255, 255, 255, .42);
    background: #fff;
    color: #7f1d1d;
}

.copy-command-button:hover {
    background: #ffe4e6;
    color: #7f1d1d;
}

.copy-command-button code {
    overflow-wrap: anywhere;
    white-space: normal;
}

.copy-feedback {
    min-height: 20px;
    color: #ffe4e6;
    font-size: 13px;
    font-weight: 800;
}

td.empty-state {
    border-bottom: 0;
}

.ticket-summary-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.ticket-summary-head h2 {
    margin-bottom: 0;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.summary-item {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.summary-item span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.summary-item strong {
    display: block;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.ticket-claim-form {
    display: flex;
    justify-content: flex-start;
    margin-top: 14px;
}

.ticket-claim-primary button {
    width: 100%;
    border-color: #B32646;
    background: #B32646;
    color: #fff;
}

.ticket-claim-primary button:hover {
    border-color: #951f3a;
    background: #951f3a;
    color: #fff;
}

.ticket-assignment-form {
    display: grid;
    grid-template-columns: auto minmax(180px, 360px) auto;
    gap: 8px;
    align-items: center;
    margin-top: 14px;
}

.ticket-assignment-label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.ticket-assignment-form select {
    width: 100%;
}

.ticket-assignment-form button {
    width: auto;
    min-width: 0;
    padding: 8px 14px;
    white-space: nowrap;
}

.ticket-assignment-form .empty-state {
    grid-column: 1 / -1;
}

@media (max-width: 720px) {
    .ticket-assignment-form {
        grid-template-columns: 1fr auto;
    }

    .ticket-assignment-label {
        grid-column: 1 / -1;
    }
}

.answer-panel textarea {
    margin-bottom: 10px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.form-actions .inline-form {
    margin: 0;
}

.ticket-action-row {
    justify-content: flex-end;
}

.switch-control {
    display: inline-grid;
    grid-template-columns: auto 54px auto;
    align-items: center;
    gap: 9px;
    justify-content: start;
    justify-self: start;
    width: max-content;
    min-height: 39px;
    color: var(--muted);
    font-weight: 700;
}

.switch-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    position: relative;
    width: 54px;
    height: 30px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .16s ease;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .28);
    transition: transform .16s ease;
}

.switch-control input:checked + .switch-track {
    background: var(--brand);
}

.switch-control input:checked + .switch-track::after {
    transform: translateX(24px);
}

.switch-control input:focus + .switch-track {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.flow-builder {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
    min-width: 0;
}

.flow-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    overflow: visible;
}

.flow-card.is-dragging {
    opacity: .55;
}

.flow-drag {
    display: grid;
    place-items: start center;
    padding-top: 22px;
    background: #eef3f8;
    color: var(--muted);
    font-size: 22px;
    cursor: grab;
    user-select: none;
}

.flow-card-body {
    padding: 16px;
    min-width: 0;
}

.flow-card-head,
.flow-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.flow-card-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.flow-add-form {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.flow-add-form label {
    margin-bottom: 0;
}

.flow-buttons {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.flow-buttons-head,
.flow-button-row-head,
.flow-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.flow-buttons-head {
    margin-bottom: 10px;
}

.flow-button-row {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.flow-button-row + .flow-button-row {
    margin-top: 10px;
}

.flow-button-row-head {
    margin-bottom: 10px;
    color: var(--muted);
    font-weight: 700;
}

.flow-button-editor {
    display: grid;
    grid-template-columns: minmax(120px, 1.2fr) minmax(120px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
    gap: 8px;
    align-items: end;
    padding: 10px 0;
    border-top: 1px solid #edf1f6;
}

.flow-button-editor:first-child {
    border-top: 0;
    padding-top: 0;
}

.flow-button-editor label {
    margin-bottom: 0;
}

.flow-card-actions {
    justify-content: flex-end;
    margin-top: 14px;
}

.flow-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: max-content;
    margin-bottom: 0;
}

.flow-toggle input {
    width: auto;
}

.scenario-list-head,
.scenario-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.scenario-list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    justify-content: flex-end;
    flex: 1 1 100%;
}

.scenario-create-form {
    flex: 1 1 520px;
}

.scenario-create-form input {
    flex: 1 1 260px;
    max-width: 520px;
}

.scenario-create-form button {
    flex: 0 0 auto;
}

.scenario-import-form {
    margin-left: auto;
}

.scenario-open-link {
    min-height: 36px;
    padding: 7px 12px;
}

.scenario-active-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle;
}

tr.is-active-scenario td {
    background: #f0fdf4;
}

.scenario-list-head h2 {
    margin-bottom: 4px;
}

.secondary-link {
    border: 1px solid #9aa4b2;
    background: #e5e9ef;
    color: var(--text);
}

.secondary-link:hover {
    background: #d8dee8;
    color: var(--text);
}

.scenario-editor {
    display: grid;
    gap: 12px;
}

.scenario-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.scenario-title {
    display: grid;
    grid-template-columns: minmax(0, auto) 18px;
    gap: 2px 8px;
    align-items: center;
    margin-right: auto;
    min-width: 0;
    max-width: min(460px, 42vw);
}

.scenario-title strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scenario-title-meta,
.scenario-status {
    color: var(--muted);
    font-size: 13px;
}

.scenario-title-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scenario-title-meta .scenario-status {
    display: inline-block;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scenario-title-meta .scenario-active-badge {
    display: inline-flex;
    flex: 0 0 auto;
    max-width: 100%;
    white-space: nowrap;
}

.scenario-save-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    opacity: .85;
}

.scenario-save-icon[hidden] {
    display: none;
}

.scenario-save-icon.is-saving {
    animation: scenario-save-pulse .8s ease-in-out infinite alternate;
}

@keyframes scenario-save-pulse {
    from {
        opacity: .45;
        transform: scale(.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scenario-status.is-error {
    color: var(--danger);
    font-weight: 700;
}

.scenario-validation-info {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    min-height: 22px;
    padding: 0;
    border: 1px solid #93c5fd;
    border-radius: 50%;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.scenario-validation-info:hover {
    border-color: #60a5fa;
    background: #dbeafe;
    color: #1e40af;
}

.scenario-validation-info[hidden] {
    display: none;
}

.scenario-shell {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 310px;
    min-height: 680px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.scenario-palette,
.scenario-inspector {
    min-width: 0;
    padding: 14px;
    background: #f8fafc;
    overflow: auto;
}

.scenario-palette {
    border-right: 1px solid var(--line);
}

.scenario-inspector {
    border-left: 1px solid var(--line);
}

.scenario-block-add {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    border-color: #cbd5e1;
    background: #fff;
    color: var(--text);
    text-align: left;
}

.scenario-block-add:hover {
    background: #edf6f9;
    color: var(--text);
}

.scenario-canvas-wrap {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
}

.scenario-canvas-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.scenario-canvas {
    position: relative;
    min-width: 0;
    min-height: 620px;
    overflow: auto;
    background-color: #f8fbff;
    background-image:
        linear-gradient(#e3e9f2 1px, transparent 1px),
        linear-gradient(90deg, #e3e9f2 1px, transparent 1px);
    background-size: 28px 28px;
}

.scenario-world {
    position: relative;
    width: 2400px;
    height: 1600px;
    transform-origin: 0 0;
}

.scenario-edges,
.scenario-nodes {
    position: absolute;
    inset: 0;
}

.scenario-edges {
    z-index: 1;
    width: 2400px;
    height: 1600px;
    overflow: visible;
    pointer-events: auto;
}

.scenario-nodes {
    z-index: 2;
}

.scenario-edges-overlay {
    z-index: 3;
    pointer-events: none;
}

.scenario-edges-overlay .scenario-edge,
.scenario-edges-overlay .scenario-edge-hit,
.scenario-edges-overlay .scenario-edge-handle,
.scenario-edges-overlay .scenario-edge-label-group,
.scenario-edges-overlay .scenario-edge-label,
.scenario-edges-overlay .scenario-edge-label-hit {
    pointer-events: all;
}

.scenario-edges-overlay .scenario-edge-preview {
    pointer-events: none;
}

.scenario-edge {
    fill: none;
    stroke: #647084;
    stroke-width: 2.5;
    cursor: pointer;
}

.scenario-edge:hover,
.scenario-edge.is-selected {
    stroke: var(--brand);
    stroke-width: 4;
}

.scenario-edge-label {
    fill: #334155;
    font: 13px Arial, Helvetica, sans-serif;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 4px;
    cursor: pointer;
}

.scenario-node {
    position: absolute;
    display: grid;
    gap: 4px;
    width: 220px;
    min-height: 108px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-top: 5px solid var(--brand);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .08);
    cursor: grab;
    user-select: none;
}

.scenario-node.is-selected {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

.scenario-node.has-error {
    outline: 3px solid #fecaca;
}

.scenario-node.has-warning {
    outline: 3px solid #fde68a;
}

.scenario-node-type {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.scenario-node strong {
    font-size: 16px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.scenario-node small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.scenario-node-ports {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.scenario-port {
    width: 20px;
    height: 20px;
    min-height: 20px;
    padding: 0;
    border-radius: 50%;
    border-color: #94a3b8;
    background: #fff;
}

.scenario-inspector label {
    margin-bottom: 12px;
}

.scenario-button-row {
    display: grid;
    gap: 8px;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.scenario-sort-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.scenario-sort-controls {
    display: inline-flex;
    gap: 4px;
}

.scenario-sort-button {
    width: 34px;
    min-height: 34px;
    padding: 0;
}

.scenario-sort-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.scenario-test-modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .42);
}

.scenario-test-modal[hidden] {
    display: none;
}

.scenario-test-dialog {
    width: min(680px, 100%);
    padding: 16px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .28);
}

.scenario-test-log {
    height: 360px;
    margin-bottom: 12px;
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.scenario-test-log div {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff;
}

.scenario-test-log .is-user {
    background: #e0f2fe;
}

.scenario-test-log .is-button {
    background: #fef3c7;
}

.scenario-validation-modal {
    position: fixed;
    z-index: 110;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .42);
}

.scenario-validation-modal[hidden] {
    display: none;
}

.scenario-validation-dialog {
    width: min(760px, 100%);
    max-height: min(720px, calc(100vh - 40px));
    padding: 16px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .28);
    overflow: auto;
}

.scenario-validation-summary {
    margin: 10px 0 12px;
    color: var(--muted);
    font-size: 14px;
}

.scenario-validation-list {
    display: grid;
    gap: 10px;
}

.scenario-validation-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 8px;
    background: #fff;
}

.scenario-validation-item.is-error {
    border-left-color: var(--danger);
    background: var(--danger-bg);
}

.scenario-validation-item.is-warning {
    border-left-color: var(--warning);
    background: var(--warning-bg);
}

.scenario-validation-item-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.scenario-validation-item-head span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.scenario-validation-item p {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.scenario-canvas-wrap {
    position: relative;
}

.scenario-canvas-tools {
    position: absolute;
    z-index: 12;
    right: 16px;
    top: 16px;
    width: 54px;
    display: grid;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
}

.scenario-canvas-tools button {
    width: 54px;
    min-height: 42px;
    padding: 8px;
    border-color: #e2e8f0;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
    font-size: 13px;
    white-space: normal;
}

.scenario-canvas {
    min-height: 760px;
    background-color: #f3f6fb;
    background-image:
        radial-gradient(circle, #d9e1ec 1px, transparent 1px);
    background-size: 24px 24px;
}

.scenario-node {
    width: 280px;
    min-height: 118px;
    gap: 0;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-top: 0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 26px rgba(15, 23, 42, .08);
}

.scenario-node.is-new {
    outline: 4px solid #ef4444;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(239, 68, 68, .16), 0 12px 26px rgba(15, 23, 42, .08);
}

.scenario-node::before {
    content: "";
    height: 4px;
    border-radius: 8px 8px 0 0;
    background: currentColor;
}

.scenario-node-head {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #eef2f7;
}

.scenario-node-icon {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.scenario-node-head strong {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.25;
}

.scenario-node-head small {
    color: #94a3b8;
    font-size: 10px;
    max-width: 64px;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scenario-node-type {
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    text-transform: none;
}

.scenario-node-media {
    height: 138px;
    margin: 0 10px 10px;
    border-radius: 7px;
    background-position: center;
    background-size: cover;
    border: 1px solid #e2e8f0;
}

.scenario-node-body {
    min-height: 54px;
    max-height: 140px;
    margin: 10px;
    padding: 10px;
    overflow: hidden;
    border-radius: 7px;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    line-height: 1.35;
    white-space: pre-wrap;
}

.scenario-node-buttons {
    display: grid;
    gap: 6px;
    padding: 0 10px 10px;
}

.scenario-node-button-row,
.scenario-node-add-answer {
    position: relative;
    min-height: 28px;
    padding: 7px 28px 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 11px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scenario-node-button-row::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    transform: translateY(-50%);
}

.scenario-button-port {
    position: absolute;
    right: 5px;
    top: 50%;
    z-index: 4;
    width: 18px;
    height: 18px;
    min-height: 18px;
    padding: 0;
    border: 3px solid #fff;
    border-radius: 999px;
    background: #ef4444;
    box-shadow: 0 0 0 1px #fecaca;
    transform: translateY(-50%);
    cursor: crosshair;
}

.scenario-button-port:hover {
    background: #dc2626;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .18);
}

.scenario-node-add-answer {
    color: #94a3b8;
    text-align: center;
}

.scenario-node-footer {
    padding: 7px 10px 10px;
    color: #94a3b8;
    font-size: 11px;
    text-align: right;
}

.scenario-port {
    position: absolute;
    z-index: 3;
    width: 14px;
    height: 14px;
    min-height: 14px;
    padding: 0;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.scenario-port:hover {
    border-color: #2563eb;
    background: #dbeafe;
}

.scenario-port-in {
    left: -7px;
    top: 86px;
}

.scenario-port-out {
    right: -7px;
    top: 86px;
}

.scenario-node-start,
.scenario-node-end,
.scenario-node-delay,
.scenario-node-tag_add,
.scenario-node-tag_remove,
.scenario-node-condition {
    min-height: 102px;
}

.scenario-node-start .scenario-node-body,
.scenario-node-end .scenario-node-body,
.scenario-node-delay .scenario-node-body,
.scenario-node-tag_add .scenario-node-body,
.scenario-node-tag_remove .scenario-node-body,
.scenario-node-condition .scenario-node-body {
    min-height: 32px;
    margin-bottom: 6px;
}

.scenario-edge {
    stroke: #c2cad8;
    stroke-width: 2;
    cursor: pointer;
    pointer-events: stroke;
}

.scenario-edge-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 18;
    cursor: pointer;
    pointer-events: stroke;
}

.scenario-edge:hover,
.scenario-edge.is-selected {
    stroke: #2563eb;
    stroke-width: 3;
}

.scenario-edge-preview {
    stroke: #2563eb;
    stroke-dasharray: 8 8;
    stroke-width: 3;
    pointer-events: none;
}

.scenario-edge-handle {
    fill: #ffffff;
    stroke: #2563eb;
    stroke-width: 3;
    cursor: grab;
    opacity: .08;
    pointer-events: all;
}

.scenario-edge-handle-from {
    stroke: #ef4444;
}

.scenario-edge-handle:hover,
.scenario-edge-handle.is-active {
    opacity: 1;
}

.scenario-edge-handle:active {
    cursor: grabbing;
}

.scenario-edge-label-group {
    cursor: pointer;
    pointer-events: all;
}

.scenario-edge-label {
    fill: #475569;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    pointer-events: all;
    user-select: none;
}

.scenario-edge-label-hit {
    fill: rgba(37, 99, 235, .001);
    cursor: pointer;
    pointer-events: all;
}

.scenario-edge-label-group:hover .scenario-edge-label,
.scenario-edge-label-group.is-selected .scenario-edge-label,
.scenario-edge-label-hit:hover + .scenario-edge-label,
.scenario-edge-label:hover,
.scenario-edge-label.is-selected {
    fill: #2563eb;
    text-decoration: underline;
}

.scenario-inspector .danger {
    width: 100%;
    margin-top: 8px;
    border-color: #fecaca;
    background: #fee2e2;
    color: #991b1b;
}

.scenario-inspector .danger:hover {
    background: #fecaca;
}

.scenario-edge-list {
    display: grid;
    gap: 8px;
    margin: 8px 0 14px;
}

.scenario-port-caption {
    margin: 6px 0 12px;
    padding: 8px 10px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 12px;
    font-weight: 700;
}

.scenario-edge-list-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
}

.scenario-edge-list-row span {
    overflow: hidden;
    color: #334155;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scenario-edge-list-row button {
    width: auto;
    min-height: 30px;
    padding: 5px 8px;
}

.scenario-editor {
    width: calc(100vw - 32px);
    margin-left: calc((100% - 100vw + 32px) / 2);
}

.page:has(.scenario-editor) {
    margin: 7px auto 56px;
}

.page:has(.scenario-editor) > h1 {
    display: none;
}

.scenario-shell {
    position: relative;
    display: block;
    min-height: calc(100vh - 170px);
}

.scenario-canvas-wrap {
    height: calc(100vh - 170px);
    min-height: 720px;
}

.scenario-canvas {
    height: 100%;
    min-height: 720px;
    cursor: grab;
}

.scenario-canvas.is-panning {
    cursor: grabbing;
}

.scenario-canvas-tools {
    width: 132px;
}

.scenario-canvas-tools select {
    width: 132px;
    min-height: 42px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
    font-size: 13px;
}

.scenario-canvas-tools button {
    width: 132px;
}

.scenario-inspector {
    position: absolute;
    z-index: 18;
    top: 14px;
    right: 164px;
    width: min(360px, calc(100% - 220px));
    max-height: calc(100% - 28px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .18);
}

.scenario-inspector[hidden] {
    display: none;
}

.test-bot-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.test-bot-form label {
    flex: 1 1 240px;
    margin-bottom: 0;
}

.test-bot-form button {
    flex: 0 1 auto;
}

.diagnostics-page {
    display: grid;
    gap: 18px;
}

.diagnostics-page h2,
.diagnostics-page h3,
.diagnostics-page h4 {
    margin-top: 0;
}

.diagnostics-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
}

.diagnostics-hero p {
    margin: 0;
    color: var(--muted);
}

.diagnostics-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.diagnostics-banner {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid #facc15;
    border-radius: 8px;
    background: #fffbeb;
}

.diagnostics-banner.is-ok {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.diagnostics-banner-main {
    display: flex;
    gap: 12px;
    align-items: center;
}

.diagnostics-pulse {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #f59e0b;
    box-shadow: 0 0 0 5px rgba(245, 158, 11, .16);
}

.diagnostics-banner.is-ok .diagnostics-pulse {
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, .16);
}

.diagnostics-metrics {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.diagnostics-metric {
    min-width: 0;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.diagnostics-metric-label,
.diagnostics-card-sub,
.diagnostics-section-meta,
.diagnostics-action-card p,
.diagnostics-url-row code,
.diagnostics-check small,
.diagnostics-quick small {
    color: var(--muted);
}

.diagnostics-metric-value {
    display: block;
    margin: 5px 0;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.diagnostics-metric-status {
    color: var(--success);
    font-size: 13px;
}

.diagnostics-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr);
    gap: 18px;
}

.diagnostics-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.diagnostics-card-title {
    margin-bottom: 3px;
}

.diagnostics-health-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.diagnostics-health-box {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.diagnostics-health-box.is-ok {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.diagnostics-health-box.is-bad {
    border-color: #fecaca;
    background: #fef2f2;
}

.diagnostics-health-box strong {
    display: block;
    font-size: 25px;
    line-height: 1.15;
}

.diagnostics-issue-list,
.diagnostics-quick-list,
.diagnostics-section-stack,
.diagnostics-url-list {
    display: grid;
    gap: 10px;
}

.diagnostics-issue-list {
    margin-top: 14px;
}

.diagnostics-issue,
.diagnostics-quick {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.diagnostics-issue.is-bad {
    border-color: #fecaca;
    background: #fff8f7;
}

.diagnostics-issue-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger);
    font-weight: 900;
}

.diagnostics-quick {
    grid-template-columns: minmax(0, 1fr) auto;
    color: var(--text);
    text-align: left;
}

.diagnostics-quick:hover {
    text-decoration: none;
}

.diagnostics-switch-control {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.diagnostics-switch-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.diagnostics-switch-control input[type="checkbox"] {
    top: 50%;
    right: 12px;
    z-index: 2;
    width: 42px;
    height: 24px;
    margin: 0;
    cursor: pointer;
    pointer-events: auto;
    transform: translateY(-50%);
}

.diagnostics-switch-control .switch-track {
    position: relative;
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #94a3b8;
}

.diagnostics-switch-control .switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .22);
    transition: transform .16s ease;
}

.diagnostics-switch-control input:checked + .switch-track {
    background: #22c55e;
}

.diagnostics-switch-control input:checked + .switch-track::after {
    transform: translateX(18px);
}

.diagnostics-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: -6px 0 14px;
    border-bottom: 1px solid var(--line);
}

.admin-section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: -6px 0 20px;
    border-bottom: 1px solid var(--line);
}

.admin-section-tab {
    padding: 10px 14px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

.admin-section-tab:hover,
.admin-section-tab.is-active {
    border-bottom-color: var(--brand);
    color: var(--brand-dark);
}

.access-user-actions {
    justify-content: flex-end;
    margin-bottom: 14px;
}

.staff-avatar {
    float: left;
    width: 44px;
    height: 44px;
    margin-right: 10px;
    border-radius: 50%;
    object-fit: cover;
    background: #eef3f8;
}

.staff-profile-preview {
    display: block;
    width: 128px;
    height: 128px;
    margin: 8px 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    object-fit: cover;
    background: #eef3f8;
}

.staff-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.staff-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.staff-card.is-inactive {
    opacity: .68;
}

.staff-card-photo {
    display: block;
    width: 100%;
    height: 230px;
    object-fit: cover;
    background: #eef3f8;
}

.staff-card-photo.is-placeholder {
    display: grid;
    place-items: center;
    color: var(--muted);
}

.staff-card-body {
    padding: 16px;
}

.staff-card-body h2 {
    margin: 0 0 4px;
}

.staff-card-biography {
    min-height: 70px;
    margin: 14px 0;
}

.profile-page-grid {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.profile-own-card {
    position: sticky;
    top: 18px;
}

.profile-form-stack {
    display: grid;
    gap: 18px;
}

.profile-form-stack .panel {
    margin: 0;
}

@media (max-width: 760px) {
    .profile-page-grid {
        grid-template-columns: 1fr;
    }

    .profile-own-card {
        position: static;
    }
}

.diagnostics-tab {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
}

.diagnostics-tab:hover,
.diagnostics-tab.is-active {
    border-bottom-color: var(--brand);
    background: transparent;
    color: var(--brand-dark);
}

.diagnostics-accordion {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.diagnostics-accordion summary {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 15px 16px;
    cursor: pointer;
}

.diagnostics-accordion summary::-webkit-details-marker {
    display: none;
}

.diagnostics-section-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f2f4f7;
}

.diagnostics-chevron {
    color: var(--muted);
    transition: transform .16s ease;
}

.diagnostics-accordion[open] .diagnostics-chevron {
    transform: rotate(180deg);
}

.diagnostics-accordion-body {
    padding: 16px;
    border-top: 1px solid var(--line);
    background: #fcfcfd;
}

.diagnostics-check-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.diagnostics-check {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.diagnostics-check i {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    border-radius: 999px;
    font-style: normal;
    font-weight: 900;
}

.diagnostics-check.is-ok i {
    background: var(--success-bg);
    color: var(--success);
}

.diagnostics-check.is-bad i {
    background: var(--danger-bg);
    color: var(--danger);
}

.diagnostics-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.diagnostics-search {
    flex: 1 1 280px;
    max-width: 430px;
}

.diagnostics-table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.diagnostics-table-wrap table {
    min-width: 760px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.diagnostics-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #475467;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.diagnostics-pill.is-ok {
    background: var(--success-bg);
    color: var(--success);
}

.diagnostics-pill.is-bad {
    background: var(--danger-bg);
    color: var(--danger);
}

.diagnostics-type-pill {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f2f4f7;
    font-size: 12px;
    font-weight: 700;
}

.diagnostics-url-row {
    display: grid;
    grid-template-columns: minmax(170px, .34fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.diagnostics-url-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
}

.diagnostics-url-field code {
    min-width: 0;
    padding: 8px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diagnostics-url-eye {
    display: inline-grid;
    place-items: center;
    width: 36px;
    min-height: 36px;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0 6px 6px 0;
    background: #fff;
    color: var(--muted);
}

.diagnostics-url-eye:hover,
.diagnostics-url-eye.is-active {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.diagnostics-copy-button {
    white-space: nowrap;
}

.diagnostics-action-groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.diagnostics-action-card {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.diagnostics-action-card p {
    margin: 0 0 10px;
}

.diagnostics-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.diagnostics-danger-zone {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fff8f7;
}

.diagnostics-hidden {
    display: none;
}

.field-action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.compact-button {
    min-height: 39px;
    white-space: nowrap;
}

.knowledge-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.knowledge-add-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.knowledge-add-icon {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.checkbox-line {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    white-space: nowrap;
}

.checkbox-line input {
    width: auto;
}

.instruction-list {
    margin: 0;
    padding-left: 22px;
    color: var(--muted);
    line-height: 1.6;
}

.knowledge-publication-text {
    margin: 0;
    padding: 14px;
    max-height: min(58vh, 560px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text);
    font: 15px/1.55 Arial, Helvetica, sans-serif;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.publication-template-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.publication-template-insert {
    margin-bottom: 18px;
}

.publication-template-insert .field-help {
    margin-top: 0;
}

.publication-template-toolbar {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
}

.publication-template-toolbar > .form-actions {
    margin: 0;
}

.publication-template-help {
    position: relative;
    flex: 0 0 auto;
}

.publication-template-help > summary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.publication-template-help > summary::-webkit-details-marker {
    display: none;
}

.publication-template-help > summary::before {
    content: "?";
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
}

.publication-template-help[open] > summary {
    border-color: var(--brand);
    color: var(--brand);
}

.publication-template-help-content {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    right: 0;
    width: min(620px, 82vw);
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .16);
}

.publication-template-help-content table {
    margin: 0;
}

.publication-template-column {
    min-width: 0;
}

.publication-template-column > label,
.publication-template-column > h3 {
    display: block;
    margin: 0 0 8px;
    min-height: 24px;
}

.publication-template-column textarea,
.publication-template-preview {
    box-sizing: border-box;
    width: 100%;
    height: 430px;
    max-height: 58vh;
}

.publication-template-column textarea {
    resize: vertical;
}

.publication-template-preview {
    min-height: 240px;
}

.knowledge-edit-form {
    display: grid;
    gap: 12px;
}

.knowledge-edit-form[hidden],
.knowledge-modal-actions[hidden] {
    display: none;
}

.knowledge-edit-form textarea {
    min-height: min(48vh, 420px);
    resize: vertical;
    font: 15px/1.55 Arial, Helvetica, sans-serif;
}

.knowledge-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
}

.knowledge-revision-history {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color, #d8dee8);
}

.knowledge-revision-history h3 {
    margin: 0 0 12px;
}

.knowledge-revision {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #d8dee8);
    border-radius: 8px;
}

.knowledge-revision summary {
    cursor: pointer;
    font-weight: 600;
}

.knowledge-revision .knowledge-publication-text {
    margin-top: 12px;
}

.danger-button {
    border-color: #b42318;
    background: #b42318;
    color: #fff;
}

.danger-button:hover {
    background: #8f1c13;
}

@media (max-width: 1100px) {
    .diagnostics-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .diagnostics-main-grid,
    .diagnostics-action-groups {
        grid-template-columns: 1fr;
    }

    .diagnostics-check-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .stats,
    .health-grid,
    .grid,
    .summary-grid,
    .settings-form,
    .analytics-filters,
    .payment-filters,
    .client-settings-grid,
    .client-subscription-summary {
        display: block;
    }

    .chat-history-filters {
        grid-template-columns: 1fr;
    }

    .chat-message,
    .chat-message-callback {
        width: 100%;
    }

    .chat-message-meta time {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        align-items: center;
        padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    }

    .pwa-install-button {
        right: max(12px, env(safe-area-inset-right));
        bottom: max(12px, env(safe-area-inset-bottom));
        max-width: calc(100vw - 24px);
    }

    .admin-menu-toggle {
        display: inline-flex;
    }

    .topbar nav {
        display: none;
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        gap: 6px;
        margin-top: 2px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, .12);
    }

    .topbar nav.is-open {
        display: grid;
    }

    .topbar nav a {
        min-height: 42px;
        padding: 9px 10px;
    }

    .topbar-push-button {
        justify-content: center;
        width: 100%;
        min-height: 42px;
        margin-left: 0;
    }

    .topbar-notification-center {
        width: 100%;
        margin-left: 0;
    }

    .notification-center-panel {
        position: fixed;
        top: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: calc(100vh - 82px);
    }

    .notification-push-status,
    .notification-category-grid {
        grid-template-columns: 1fr;
    }

    .summary-item {
        margin-bottom: 10px;
    }

    .ticket-summary-head {
        display: grid;
    }

    .stats div {
        margin-top: 12px;
    }

    .payment-filters label,
    .payment-filter-actions {
        margin-top: 12px;
    }

    .tickets-toolbar {
        display: none;
    }

    .mobile-filter {
        display: block;
    }

    .mobile-filter-action {
        display: block;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    .field-action-row {
        grid-template-columns: 1fr;
    }

    .compact-button {
        width: 100%;
    }

    .knowledge-actions {
        display: grid;
    }

    .flow-card {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .flow-card-head,
    .flow-card-grid,
    .flow-add-form,
    .flow-button-editor {
        grid-template-columns: 1fr;
    }

    .test-bot-form {
        display: block;
    }

    .test-bot-form button {
        margin-top: 10px;
        width: 100%;
    }

    .diagnostics-hero,
    .diagnostics-banner,
    .diagnostics-danger-zone {
        display: grid;
    }

    .diagnostics-hero-actions {
        justify-content: flex-start;
    }

    .diagnostics-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .diagnostics-health-summary,
    .diagnostics-check-grid {
        grid-template-columns: 1fr;
    }

    .diagnostics-accordion summary {
        grid-template-columns: 36px minmax(0, 1fr) auto;
    }

    .diagnostics-accordion summary .diagnostics-chevron {
        display: none;
    }

    .diagnostics-issue {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .diagnostics-issue .button-link,
    .diagnostics-issue button {
        grid-column: 2;
        justify-self: start;
    }

    .diagnostics-url-row {
        grid-template-columns: 1fr;
    }

    .diagnostics-url-field code {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .diagnostics-copy-button {
        justify-self: start;
    }

    .settings-save-bar {
        display: block;
    }

    .settings-save-bar button {
        width: 100%;
    }

    .admin-modal {
        padding: 10px;
    }

    .admin-modal-head {
        display: grid;
    }

    .scenario-shell {
        grid-template-columns: 1fr;
    }

    .scenario-palette,
    .scenario-inspector {
        border: 0;
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 800px) {
    .publication-template-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .publication-template-help {
        justify-self: end;
    }

    .publication-template-help-content {
        width: min(620px, calc(100vw - 48px));
        overflow-x: auto;
    }

    .publication-template-workspace {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .publication-template-column textarea,
    .publication-template-preview {
        height: 360px;
        max-height: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Traffic sources: compact registry with modal editing */
.traffic-sources-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.traffic-sources-heading p {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
}

.traffic-sources-heading-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

.traffic-sources-controls {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(190px, 240px);
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
}

.traffic-sources-controls label {
    gap: 5px;
    margin: 0;
    font-size: 13px;
}

.traffic-sources-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.traffic-sources-table {
    min-width: 1040px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.traffic-sources-table th,
.traffic-sources-table td {
    padding: 10px 12px;
    vertical-align: middle;
}

.traffic-sources-table th {
    white-space: nowrap;
}

.traffic-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-weight: 700;
}

.traffic-sort-button:hover {
    background: transparent;
    color: var(--brand-dark);
}

.traffic-sort-button span {
    color: var(--muted);
    font-size: 12px;
}

.traffic-number-heading,
.traffic-source-number {
    text-align: right;
}

.traffic-source-main {
    width: 25%;
    min-width: 210px;
}

.traffic-source-title {
    display: block;
    width: fit-content;
    max-width: 100%;
    overflow: hidden;
    color: var(--brand-dark);
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.traffic-source-description {
    display: block;
    max-width: 340px;
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.traffic-source-link-cell {
    width: 26%;
    min-width: 230px;
}

.traffic-source-link-cell code {
    display: block;
    width: fit-content;
    max-width: 100%;
    overflow: hidden;
    color: var(--brand-dark);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.traffic-source-link {
    display: block;
    max-width: 310px;
    margin-top: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.traffic-link-warning {
    display: inline;
    min-height: 0;
    margin-top: 3px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--warning);
    font-size: 12px;
    text-align: left;
}

.traffic-link-warning:hover {
    background: transparent;
    color: var(--brand-dark);
    text-decoration: underline;
}

.traffic-source-number {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.traffic-source-number a {
    color: var(--text);
    font-weight: 800;
}

.traffic-source-number a:hover {
    color: var(--brand);
}

.traffic-source-revenue {
    min-width: 125px;
}

.traffic-source-status {
    white-space: nowrap;
}

.traffic-source-actions {
    display: flex;
    min-width: 210px;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.traffic-source-actions .compact-button {
    padding: 7px 9px;
    font-size: 13px;
}

.traffic-copy-button.is-copied {
    border-color: #86c89c;
    background: var(--success-bg);
    color: var(--success);
}

.traffic-sources-summary {
    margin: 9px 2px 0;
    color: var(--muted);
    font-size: 13px;
}

.traffic-source-modal-dialog {
    width: min(620px, 100%);
}

.traffic-modal-actions {
    justify-content: flex-end;
    margin-top: 2px;
}

.traffic-source-active-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    width: fit-content;
    margin: 0;
    color: var(--text);
}

.traffic-source-active-toggle .checkbox-input {
    flex: 0 0 auto;
}

.traffic-copy-fallback {
    position: fixed;
    top: -1000px;
    left: -1000px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 900px) {
    .traffic-sources-heading {
        align-items: stretch;
    }

    .traffic-sources-heading-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .traffic-sources-heading-actions button {
        min-height: 44px;
    }

    .traffic-sources-table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .traffic-sources-table {
        display: block;
        min-width: 0;
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .traffic-sources-table thead {
        display: none;
    }

    .traffic-sources-table tbody {
        display: grid;
        gap: 10px;
    }

    .traffic-sources-table tr[data-source-row] {
        display: grid;
        grid-template-columns: minmax(0, 1fr) repeat(3, auto);
        grid-template-areas:
            "source source status status"
            "link link link link"
            "users tickets revenue revenue"
            "actions actions actions actions";
        gap: 12px 16px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
        box-shadow: var(--shadow);
    }

    .traffic-sources-table tr[data-source-row][hidden] {
        display: none;
    }

    .traffic-sources-table td {
        display: block;
        width: auto;
        min-width: 0;
        padding: 0;
        border: 0;
        text-align: left;
    }

    .traffic-sources-table td[data-label]::before {
        display: block;
        margin-bottom: 2px;
        color: var(--muted);
        content: attr(data-label);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .02em;
        text-transform: uppercase;
    }

    .traffic-source-main {
        grid-area: source;
    }

    .traffic-source-main::before,
    .traffic-source-status::before,
    .traffic-source-actions::before {
        display: none !important;
    }

    .traffic-source-description,
    .traffic-source-link {
        max-width: none;
    }

    .traffic-source-status {
        grid-area: status;
        justify-self: end;
    }

    .traffic-source-link-cell {
        grid-area: link;
    }

    .traffic-source-number:nth-of-type(3) {
        grid-area: users;
    }

    .traffic-source-number:nth-of-type(4) {
        grid-area: tickets;
    }

    .traffic-source-revenue {
        grid-area: revenue;
        justify-self: end;
        text-align: right !important;
    }

    .traffic-source-actions {
        grid-area: actions;
        min-width: 0;
        padding-top: 10px !important;
        border-top: 1px solid var(--line) !important;
    }

    .traffic-source-actions .compact-button {
        width: auto;
        min-height: 42px;
    }

    .traffic-sources-table tr[data-source-filter-empty] {
        display: block;
        padding: 20px 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
    }

    .traffic-sources-table tr[data-source-filter-empty][hidden] {
        display: none;
    }

    .traffic-sources-table tr[data-source-filter-empty] td {
        display: block;
    }

    .traffic-sources-table .traffic-sources-empty-row {
        display: block;
        padding: 20px 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
    }

    .traffic-sources-table .traffic-sources-empty-row td {
        display: block;
    }
}

@media (max-width: 620px) {
    .traffic-sources-heading {
        display: grid;
    }

    .traffic-sources-heading-actions,
    .traffic-sources-controls {
        grid-template-columns: 1fr;
    }

    .traffic-sources-heading-actions .secondary {
        order: 2;
    }

    .traffic-sources-table tr[data-source-row] {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "source status"
            "link link"
            "users tickets"
            "revenue revenue"
            "actions actions";
    }

    .traffic-source-revenue {
        justify-self: start;
        text-align: left !important;
    }

    .traffic-source-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .traffic-source-actions .compact-button {
        width: 100%;
    }

    .traffic-modal-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .traffic-modal-actions button {
        width: 100%;
    }
}

/* CRM usability refresh: role-aware navigation, ticket workspace and mobile UI */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 64px;
    padding: 10px 22px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .12);
}

.brand {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-main-nav {
    min-width: 0;
    align-items: center;
    gap: 4px !important;
}

.nav-icon {
    flex: 0 0 auto;
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-group {
    position: relative;
}

.nav-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 7px 9px;
    border-color: transparent;
    background: transparent;
    color: #dbeafe;
    font-size: 14px;
    white-space: nowrap;
}

.nav-group-toggle:hover,
.nav-group.is-active > .nav-group-toggle,
.nav-group.is-open > .nav-group-toggle {
    border-color: rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.nav-chevron {
    display: inline-block;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: url('/assets/img/nav-chevron-down.svg') center / contain no-repeat;
    mask: url('/assets/img/nav-chevron-down.svg') center / contain no-repeat;
    transition: transform .16s ease;
}

.nav-group.is-open .nav-chevron {
    transform: rotate(180deg);
}

.nav-group-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: none;
    width: max-content;
    min-width: 230px;
    max-width: 310px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .2);
}

.nav-group.is-open .nav-group-panel,
.nav-group:focus-within .nav-group-panel {
    display: grid;
    gap: 3px;
}

.nav-group-label {
    padding: 6px 8px 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.topbar .nav-group-panel a {
    width: 100%;
    min-height: 40px;
    color: var(--text);
}

.topbar .nav-group-panel a:hover,
.topbar .nav-group-panel a.is-active {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.nav-account-group {
    margin-left: auto;
}

.nav-account-panel {
    right: 0;
    left: auto;
}

.topbar-notification-center {
    margin-left: 4px;
}

.topbar-push-button {
    min-height: 38px;
}

.notification-center-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.notification-center-panel .notification-install-button {
    position: static;
    display: inline-flex;
    width: 100%;
    max-width: none;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--brand);
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    box-shadow: none;
}

.notification-center-panel .notification-install-button:hover {
    background: var(--brand-dark);
}

.notification-center-panel .notification-install-button[hidden] {
    display: none;
}

.page {
    width: min(100%, 1480px);
    margin-inline: auto;
    padding-top: 24px;
}

.page-back-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    margin: -8px 0 14px;
    color: var(--muted);
    font-weight: 700;
}

.page-back-link:hover {
    color: var(--brand-dark);
}

.mobile-bottom-nav,
.mobile-field-label {
    display: none;
}

.tickets-table-wrap {
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.tickets-table {
    min-width: 1160px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.tickets-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
}

.tickets-table .ticket-row {
    cursor: pointer;
}

.tickets-table .ticket-row:focus-visible {
    outline: 3px solid rgba(23, 107, 135, .28);
    outline-offset: -3px;
}

.tickets-table .ticket-row-new td {
    background: #fffdf5;
}

.tickets-table .ticket-row-new td:first-child {
    border-left: 4px solid #d97706;
}

.tickets-table .ticket-number strong {
    color: var(--brand-dark);
    white-space: nowrap;
}

/* System backups */
.backup-info { position:relative; z-index:45; float:right; margin-top:-52px; }
.backup-info > summary { display:grid; place-items:center; width:36px; height:36px; border:1px solid var(--line-strong); border-radius:50%; background:#fff; color:var(--brand); box-shadow:var(--shadow); cursor:pointer; font:800 18px/1 Georgia,serif; list-style:none; }
.backup-info > summary::-webkit-details-marker { display:none; }
.backup-info[open] > summary { border-color:var(--brand); background:var(--brand-soft); }
.backup-info-popover { position:absolute; top:44px; right:0; width:min(440px,calc(100vw - 32px)); padding:18px; border:1px solid var(--line); border-radius:12px; background:#fff; box-shadow:0 16px 40px rgba(15,23,42,.16); }
.backup-info-popover h2 { margin:0 0 10px; font-size:18px; }
.backup-info-popover p { margin:8px 0; color:var(--muted); }
.backup-create-panel { display:grid; clear:both; grid-template-columns:minmax(210px,.75fr) minmax(0,3fr); gap:24px; align-items:center; border-color:#c9dce6; background:linear-gradient(135deg,#f8fbff,#eef6ff); }
.backup-create-heading h2 { margin:4px 0 6px; }
.backup-create-heading > p:last-child { max-width:310px; margin:0; color:var(--muted); font-size:13px; line-height:1.45; }
.backup-create-form { display:flex; gap:16px; align-items:stretch; min-width:0; }
.backup-component-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; flex:1 1 auto; }
.backup-component-options label { display:grid; grid-template-columns:auto minmax(0,1fr); gap:10px; align-items:center; min-width:0; min-height:76px; margin:0; padding:12px 14px; border:1px solid var(--line); border-radius:10px; background:#fff; color:var(--text); cursor:pointer; overflow:hidden; }
.backup-component-options label:has(input:checked) { border-color:#86b8ca; background:#f7fcff; }
.backup-component-options input { width:auto; min-width:16px; height:16px; margin:0; padding:0; }
.backup-component-options span { display:grid; min-width:0; }
.backup-component-options strong { overflow-wrap:anywhere; line-height:1.25; }
.backup-component-options small { margin-top:3px; color:var(--muted); font-size:11px; font-weight:500; line-height:1.3; overflow-wrap:anywhere; }
.backup-create-form > button { display:flex; flex:0 0 auto; min-width:195px; flex-direction:column; align-items:center; justify-content:center; gap:2px; }
.backup-create-form > button span { color:inherit; font-weight:800; }
.backup-create-form > button small { color:rgba(255,255,255,.78); font-size:11px; font-weight:600; }
.backup-create-form > button:disabled { opacity:.68; cursor:not-allowed; }
.backup-create-form > button.is-running { cursor:wait; }
.backup-progress { grid-column:1 / -1; padding:15px 16px; border:1px solid #b8d6e3; border-radius:10px; background:#fff; }
.backup-progress[hidden] { display:none; }
.backup-progress-head { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; margin-bottom:10px; }
.backup-progress-head > div { display:grid; gap:3px; }
.backup-progress-head strong { color:var(--text); font-size:14px; }
.backup-progress-head span { color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
.backup-progress-head b { flex:0 0 auto; color:var(--brand); font-size:16px; }
.backup-progress-track { height:10px; overflow:hidden; border-radius:999px; background:#dfe8ef; }
.backup-progress-track span { display:block; width:0; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--brand),#39a1bf); transition:width .35s ease; }
.backup-progress.is-completed { border-color:#9bd4ac; background:#f3fbf5; }
.backup-progress.is-completed .backup-progress-track span { background:#16803c; }
.backup-progress.is-failed { border-color:#efaaa4; background:#fff7f6; }
.backup-progress.is-failed .backup-progress-head b,.backup-progress.is-failed .backup-progress-head strong { color:var(--danger); }
.backup-progress.is-failed .backup-progress-track span { background:var(--danger); }
.backup-actions label { display:flex; gap:8px; align-items:center; }
.backup-stats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin:16px 0; }
.backup-stats .stat-card { display:grid; min-height:112px; gap:6px; align-content:start; border-top:3px solid transparent; }
.backup-stats .backup-stat-primary { border-top-color:var(--brand); }
.backup-stats span,.backup-table small { display:block; color:var(--muted); font-size:12px; }
.backup-stats .stat-card > strong { font-size:17px; line-height:1.3; }
.backup-stats .stat-card > small { margin-top:auto; color:var(--muted); }
.backup-ok { color:#16803c; }
.backup-danger { color:#b42318 !important; }
.backup-warning { border-color:#f5c36b; background:#fffaf0; }
.backup-danger-panel { border-color:#f0aaa5; background:#fffafa; }
.backup-collapsible { padding:0; overflow:visible; }
.backup-collapsible > summary { display:flex; min-height:70px; align-items:center; gap:16px; padding:16px 18px; cursor:pointer; list-style:none; }
.backup-collapsible > summary::-webkit-details-marker { display:none; }
.backup-collapsible > summary > span { display:grid; gap:4px; }
.backup-collapsible > summary strong { font-size:16px; }
.backup-collapsible > summary small { color:var(--muted); font-size:12px; font-weight:500; }
.backup-collapsible > summary > b { display:flex; align-items:center; gap:7px; margin-left:auto; color:var(--brand); font-size:13px; }
.backup-collapsible > summary > b::after { content:'›'; font-size:21px; line-height:1; transform:rotate(90deg); transition:transform .16s ease; }
.backup-collapsible[open] > summary { border-bottom:1px solid var(--line); }
.backup-collapsible[open] > summary > b::after { transform:rotate(-90deg); }
.backup-collapsible > form,.backup-collapsible > .table-scroll,.backup-collapsible > .empty-state,.backup-collapsible > .backup-danger-intro { margin:16px 18px 18px; }
.backup-collapsible > .table-scroll { width:calc(100% - 36px); }
.backup-settings-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; align-items:end; }
.backup-settings-grid label,.backup-import-form label { display:grid; gap:6px; }
.backup-settings-grid .checkbox-field { display:flex; align-items:center; }
.backup-section-head { display:flex; align-items:end; justify-content:space-between; gap:16px; margin-bottom:16px; }
.backup-section-head h2 { margin:3px 0 0; }
.backup-section-head > span { padding:5px 10px; border-radius:999px; background:var(--panel-soft); color:var(--muted); font-size:12px; font-weight:800; }
.backup-empty { padding:42px 20px; border:1px dashed var(--line-strong); border-radius:10px; text-align:center; }
.backup-empty b { font-size:16px; }
.backup-empty p { margin:7px 0 0; color:var(--muted); }
.backup-table td { vertical-align:middle; }
.backup-table td:first-child { min-width:230px; }
.backup-name-row { display:flex; flex-wrap:wrap; align-items:center; gap:7px; margin-bottom:4px; }
.backup-status,.backup-operation-status { display:inline-flex; width:max-content; align-items:center; padding:3px 8px; border-radius:999px; background:#eef2f6; color:#526173; font-size:11px; font-weight:800; }
.backup-status.status-completed,.backup-operation-status.is-completed { background:#eaf7ee; color:#16733a; }
.backup-status.status-failed,.backup-status.status-corrupt,.backup-operation-status.is-failed { background:#fff0ef; color:var(--danger); }
.backup-status.status-creating,.backup-operation-status.is-queued,.backup-operation-status.is-starting,.backup-operation-status.is-running { background:#fff6e5; color:#9a5b00; }
.backup-components { display:flex; flex-wrap:wrap; gap:5px; }
.backup-components span { padding:4px 7px; border:1px solid #d6e3ea; border-radius:6px; background:#f5f9fb; color:#40566a; font-size:11px; font-weight:700; }
.backup-verified { color:#16803c; font-weight:800; }
.backup-actions { display:flex; flex-wrap:wrap; gap:7px; min-width:235px; }
.backup-actions details { position:relative; }
.backup-actions summary { display:flex; min-height:34px; align-items:center; padding:5px 9px; border:1px solid var(--line); border-radius:7px; background:#fff; cursor:pointer; color:var(--brand); font-weight:700; font-size:12px; list-style:none; }
.backup-actions summary::-webkit-details-marker { display:none; }
.backup-actions details[open] summary { border-color:var(--brand); background:var(--brand-soft); }
.backup-actions details[open]::before { position:fixed; z-index:59; inset:0; background:rgba(15,23,42,.42); content:''; }
.backup-actions .backup-delete summary { color:var(--danger); }
.backup-actions details form { position:fixed; z-index:60; top:50%; left:50%; display:grid; width:min(360px,calc(100vw - 32px)); max-height:calc(100vh - 48px); gap:9px; padding:18px; overflow-y:auto; border:1px solid var(--line); border-radius:12px; background:#fff; box-shadow:0 22px 60px rgba(15,23,42,.28); transform:translate(-50%,-50%); }
.backup-actions details form > small { color:var(--muted); line-height:1.4; }
.backup-actions details.backup-restore form { width:min(430px,calc(100vw - 32px)); }
.backup-actions .backup-field-label { display:grid; gap:5px; align-items:stretch; color:var(--muted); font-size:12px; }
.backup-dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:4px; }
.backup-danger-collapsible > summary { background:#fffafa; }
.backup-danger-intro { padding:12px 14px; border:1px solid #f0c1bd; border-radius:9px; background:#fff8f7; }
.backup-danger-intro strong { color:var(--danger); }
.backup-danger-intro p { margin:5px 0 0; color:var(--muted); font-size:13px; }
.backup-import-form { display:grid; grid-template-columns:2fr 1fr 1fr auto; gap:12px; align-items:end; }
@media (max-width:1050px) { .backup-create-panel{grid-template-columns:1fr}.backup-create-form{display:grid}.backup-create-form>button{min-height:44px}.backup-component-options{grid-template-columns:repeat(3,minmax(0,1fr))} }
@media (max-width:900px) { .backup-stats,.backup-settings-grid,.backup-import-form{grid-template-columns:1fr 1fr}.backup-stats{grid-template-columns:1fr 1fr} }
@media (max-width:700px) { .backup-component-options{grid-template-columns:1fr}.backup-info{margin-top:-48px}.backup-info-popover{position:fixed;top:76px;right:16px;left:16px;width:auto}.backup-stats{grid-template-columns:1fr;gap:0;overflow:hidden;border:1px solid var(--line);border-radius:10px;background:#fff}.backup-stats .stat-card{min-height:0;padding:12px 14px;border-top:0;border-bottom:1px solid var(--line)}.backup-stats .stat-card:last-child{border-bottom:0}.backup-stats .backup-stat-primary{border-left:3px solid var(--brand)}.backup-stats .stat-card>strong{font-size:16px}.backup-stats .stat-card>small{margin-top:2px}.backup-settings-grid,.backup-import-form{grid-template-columns:1fr}.backup-create-form>button{width:100%;min-height:54px}.backup-collapsible>summary{padding:14px}.backup-collapsible>summary>b{font-size:0}.backup-collapsible>summary>b::after{font-size:22px}.backup-collapsible>form,.backup-collapsible>.table-scroll,.backup-collapsible>.empty-state,.backup-collapsible>.backup-danger-intro{margin:14px}.backup-collapsible>.table-scroll{width:calc(100% - 28px)}.backup-table thead{display:none}.backup-table,.backup-table tbody,.backup-table td{display:block;width:100%}.backup-table tr{display:grid;width:100%;grid-template-columns:minmax(0,1fr) minmax(0,1fr);margin-bottom:12px;padding:0 12px;border:1px solid var(--line);border-radius:10px;background:#fff;overflow:hidden}.backup-table td{display:block;min-width:0!important;padding:10px 8px;border-bottom:1px solid var(--line)}.backup-table td:nth-child(odd){padding-left:0}.backup-table td:nth-child(even){padding-right:0}.backup-table td:first-child,.backup-table td:last-child{grid-column:1/-1;padding-right:0;padding-left:0}.backup-table td:nth-child(2),.backup-table td:nth-child(4){padding-right:12px}.backup-table td:nth-child(3),.backup-table td:nth-child(5){padding-left:12px;border-left:1px solid var(--line)}.backup-table td:last-child{border-bottom:0}.backup-table td::before{display:block;margin-bottom:6px;content:attr(data-label);color:var(--muted);font-size:11px;font-weight:700;text-transform:uppercase}.backup-table td:first-child::before{display:none}.backup-table td>small{margin-top:4px;overflow-wrap:anywhere}.backup-name-row{justify-content:space-between}.backup-components{gap:4px}.backup-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));min-width:0}.backup-actions>form,.backup-actions>details{min-width:0}.backup-actions button,.backup-actions summary{width:100%;justify-content:center;white-space:normal;text-align:center}.backup-actions details form,.backup-actions details.backup-restore form{width:calc(100vw - 28px);min-width:0;max-height:calc(100vh - 32px)}.backup-section-head{align-items:center}}

.tickets-table .ticket-question {
    min-width: 240px;
    max-width: 380px;
    color: var(--text);
    line-height: 1.45;
}

.ticket-open-link {
    justify-content: center;
    min-width: 88px;
}

.compact-notice {
    padding: 0;
    overflow: hidden;
}

.compact-notice > summary {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 56px;
    padding: 11px 14px;
    cursor: pointer;
    list-style: none;
}

.compact-notice > summary::-webkit-details-marker {
    display: none;
}

.compact-notice > summary::after {
    width: 20px;
    height: 20px;
    margin-left: auto;
    background: currentColor;
    color: var(--muted);
    content: "";
    -webkit-mask: url('/assets/img/nav-chevron-down.svg') center / contain no-repeat;
    mask: url('/assets/img/nav-chevron-down.svg') center / contain no-repeat;
    transition: transform .16s ease;
}

.compact-notice[open] > summary::after {
    transform: rotate(180deg);
}

.compact-notice > summary > span:nth-child(2) {
    display: grid;
}

.compact-notice > summary small {
    color: var(--muted);
    font-weight: 500;
}

.compact-notice-icon {
    display: grid;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: var(--warning-bg);
    color: var(--warning);
    font-weight: 900;
}

.compact-notice:not(.telegram-link-warning-panel) .compact-notice-icon {
    background: var(--success-bg);
    color: var(--success);
}

.compact-notice-body {
    margin: 0;
    padding: 0 14px 14px;
    border-top: 1px solid var(--line);
}

.ticket-primary-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ticket-service-details {
    margin-top: 12px;
    border-top: 1px solid var(--line);
}

.ticket-service-details > summary {
    padding: 12px 2px 0;
    cursor: pointer;
    color: var(--brand);
    font-weight: 700;
}

.ticket-service-details[open] > summary {
    margin-bottom: 12px;
}

.knowledge-routing-panel {
    border-style: dashed;
    background: var(--panel-soft);
    box-shadow: none;
}

.conversation-panel {
    background: #eef3f7;
}

.section-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-heading-row h2 {
    margin: 0;
}

.message-count {
    display: inline-grid;
    min-width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.conversation-panel .message {
    width: fit-content;
    max-width: 82%;
    min-width: min(280px, 70%);
    border-left-width: 1px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}

.conversation-panel .message.client {
    margin-right: auto;
    border-color: #f2c879;
    border-bottom-left-radius: 2px;
    background: #fffaf0;
}

.conversation-panel .message.specialist,
.conversation-panel .message.admin {
    margin-left: auto;
    border-color: #acd3df;
    border-bottom-right-radius: 2px;
    background: #eefbff;
}

.message-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
}

.message-meta strong {
    color: var(--text);
}

.message-meta span {
    color: var(--muted);
    font-size: 12px;
}

.answer-panel {
    border-color: #b9d5df;
}

.ticket-primary-actions {
    justify-content: flex-end;
}

.ticket-primary-actions button {
    min-width: 180px;
}

.ticket-secondary-actions {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.dashboard-intro {
    max-width: 760px;
    margin: -8px 0 18px;
    color: var(--muted);
}

.dashboard-intro p {
    margin: 0;
}

.stats .stat-card {
    position: relative;
    display: flex;
    min-height: 150px;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.stats .stat-card:hover {
    border-color: #a9c0cf;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .09);
    text-decoration: none;
    transform: translateY(-1px);
}

.stats .stat-card-attention {
    border-top: 4px solid #d97706;
}

.stats .stat-label {
    color: var(--muted);
    font-weight: 700;
}

.stats .stat-action {
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
}

.specialist-dashboard-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: .58;
}

button.is-loading,
form.is-submitting button[type="submit"] {
    cursor: wait;
    opacity: .72;
}

body.admin-modal-open {
    overflow: hidden;
}

@media (max-width: 1180px) and (min-width: 901px) {
    .nav-group-toggle {
        padding-inline: 7px;
        font-size: 13px;
    }

    .nav-account-group .nav-group-toggle span:not(.nav-chevron) {
        display: none;
    }
}

@media (max-width: 900px) {
    body {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
        font-size: 15px;
    }

    input,
    textarea,
    select,
    button {
        min-height: 44px;
        font-size: 16px;
    }

    h1 {
        margin-bottom: 16px;
        font-size: 23px;
    }

    h2 {
        font-size: 18px;
    }

    .page {
        padding: 18px 12px 28px;
    }

    .panel {
        padding: 14px;
        margin-bottom: 12px;
    }

    .topbar {
        min-height: 58px;
        padding-right: 68px;
    }

    .brand {
        max-width: calc(100vw - 170px);
    }

    .admin-menu-toggle {
        justify-self: end;
        min-height: 42px;
    }

    .topbar.has-notification-center .admin-menu-toggle {
        margin-right: 48px;
    }

    .admin-menu-toggle .nav-icon {
        width: 20px;
        height: 20px;
    }

    .admin-main-nav {
        max-height: calc(100vh - 138px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .nav-group {
        border-bottom: 1px solid rgba(255, 255, 255, .1);
    }

    .nav-group-toggle {
        display: none;
    }

    .nav-group-panel,
    .nav-group.is-open .nav-group-panel,
    .nav-group:focus-within .nav-group-panel {
        position: static;
        display: grid;
        width: 100%;
        max-width: none;
        padding: 5px 0 9px;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .nav-group-label {
        color: #9fb7cd;
    }

    .topbar .nav-group-panel a {
        color: #dbeafe;
    }

    .topbar .nav-group-panel a:hover,
    .topbar .nav-group-panel a.is-active {
        background: rgba(255, 255, 255, .11);
        color: #fff;
    }

    .nav-account-panel {
        grid-template-columns: 1fr 1fr !important;
    }

    .topbar-notification-center {
        position: absolute;
        top: max(8px, env(safe-area-inset-top));
        right: 14px;
        width: 44px;
        margin: 0;
    }

    .topbar-push-button {
        width: 44px;
        min-height: 42px;
        padding: 8px;
    }

    .topbar-push-button > span:not(.topbar-push-icon):not(.notification-count-badge) {
        display: none;
    }

    .notification-count-badge {
        position: absolute;
        top: -4px;
        right: -4px;
    }

    .notification-center-panel {
        top: auto;
        right: 0;
        bottom: calc(66px + env(safe-area-inset-bottom));
        left: 0;
        width: 100%;
        max-height: min(72vh, 620px);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -18px 46px rgba(15, 23, 42, .24);
    }

    .mobile-bottom-nav {
        position: fixed;
        z-index: 110;
        right: 0;
        bottom: 0;
        left: 0;
        display: flex;
        min-height: calc(62px + env(safe-area-inset-bottom));
        align-items: stretch;
        justify-content: space-around;
        padding: 5px 6px max(5px, env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 -5px 20px rgba(15, 23, 42, .1);
        backdrop-filter: blur(12px);
    }

    .mobile-bottom-nav a,
    .mobile-bottom-nav button {
        display: grid;
        min-width: 62px;
        min-height: 52px;
        padding: 4px 8px;
        place-items: center;
        gap: 1px;
        border: 0;
        border-radius: 7px;
        background: transparent;
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        line-height: 1.1;
    }

    .mobile-bottom-nav a.is-active {
        background: var(--brand-soft);
        color: var(--brand-dark);
    }

    .mobile-bottom-nav .nav-icon {
        width: 22px;
        height: 22px;
    }

    .mobile-filter {
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    .mobile-filter label {
        gap: 2px;
        font-size: 13px;
    }

    .tickets-table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .tickets-table {
        display: block;
        min-width: 0;
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .tickets-table thead {
        display: none;
    }

    .tickets-table tbody {
        display: grid;
        gap: 10px;
    }

    .tickets-table .tickets-empty-row {
        display: block;
        padding: 20px 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        text-align: center;
    }

    .tickets-table .tickets-empty-row td {
        display: block;
    }

    .tickets-table .ticket-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "number status"
            "topic topic"
            "question question"
            "client client"
            "assignee created"
            "access access"
            "action action";
        gap: 10px 12px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        box-shadow: var(--shadow);
    }

    .tickets-table .ticket-row-new {
        border-left: 4px solid #d97706;
        background: #fffdf7;
    }

    .tickets-table .ticket-row-new td,
    .tickets-table .ticket-row-new td:first-child {
        border-left: 0;
        background: transparent;
    }

    .tickets-table td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
        overflow-wrap: anywhere;
    }

    .tickets-table td[data-label]::before {
        display: block;
        margin-bottom: 2px;
        color: var(--muted);
        content: attr(data-label);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .02em;
        text-transform: uppercase;
    }

    .tickets-table .ticket-number {
        grid-area: number;
    }

    .tickets-table .ticket-number::before {
        display: none !important;
    }

    .mobile-field-label {
        display: inline;
        margin-right: 4px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

    .tickets-table .ticket-status {
        grid-area: status;
        justify-self: end;
    }

    .tickets-table .ticket-status::before,
    .tickets-table .ticket-access::before {
        display: none !important;
    }

    .tickets-table .ticket-topic {
        grid-area: topic;
        font-size: 16px;
        font-weight: 750;
    }

    .tickets-table .ticket-question {
        grid-area: question;
        min-width: 0;
        max-width: none;
        padding: 10px 0;
        border-top: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
    }

    .tickets-table .ticket-client {
        grid-area: client;
    }

    .tickets-table .ticket-assignee {
        grid-area: assignee;
    }

    .tickets-table .ticket-created {
        grid-area: created;
        justify-self: end;
        text-align: right;
    }

    .tickets-table .ticket-access {
        grid-area: access;
    }

    .tickets-table .ticket-open-cell {
        grid-area: action;
    }

    .ticket-open-link {
        width: 100%;
        min-height: 44px;
    }

    .ticket-summary-head,
    .ticket-summary-actions {
        gap: 10px;
    }

    .ticket-summary-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .ticket-primary-summary,
    .ticket-service-details .summary-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .summary-item {
        margin-bottom: 0;
        padding: 10px 11px;
    }

    .ticket-assignment-form {
        grid-template-columns: 1fr;
    }

    .ticket-assignment-form button,
    .ticket-claim-form button {
        width: 100%;
    }

    .conversation-panel {
        margin-inline: -12px;
        padding-inline: 12px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .conversation-panel .message {
        min-width: 0;
        max-width: 94%;
        padding: 10px 12px;
    }

    .message-meta {
        display: grid;
    }

    .answer-panel textarea {
        min-height: 150px;
    }

    .ticket-primary-actions {
        position: sticky;
        z-index: 20;
        bottom: calc(64px + env(safe-area-inset-bottom));
        margin: 10px -14px -14px;
        padding: 10px 14px;
        border-top: 1px solid var(--line);
        background: rgba(255, 255, 255, .96);
        box-shadow: 0 -8px 20px rgba(15, 23, 42, .08);
        backdrop-filter: blur(10px);
    }

    .ticket-primary-actions button,
    .ticket-secondary-actions button,
    .ticket-secondary-actions .inline-form,
    .ticket-publication-action {
        width: 100%;
    }

    .ticket-secondary-actions {
        display: grid;
        justify-content: stretch;
    }

    .stats,
    .specialist-dashboard-stats {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stats .stat-card {
        min-height: 120px;
        margin: 0;
        padding: 15px;
    }

    .admin-modal {
        align-items: flex-end;
        padding: 0;
    }

    .admin-modal-dialog {
        width: 100%;
        max-width: none;
        max-height: calc(100vh - env(safe-area-inset-top));
        margin: 0;
        padding: 16px;
        border-radius: 12px 12px 0 0;
        overflow-y: auto;
    }

    .form-actions:not(.ticket-action-row) > button,
    .form-actions:not(.ticket-action-row) > .button-link {
        width: 100%;
        justify-content: center;
    }
}
