: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);
}

* {
    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;
}

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;
}

.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 {
    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-push-button {
    min-height: 34px;
    padding: 6px 10px;
    border-color: rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 13px;
}

.topbar-push-button:hover {
    background: rgba(255, 255, 255, .18);
}

.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;
}

.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-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;
}

.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);
}

.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);
}

.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;
}

.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);
}

.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;
}

.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;
}

.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-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-form button {
    width: 100%;
    border-color: #B32646;
    background: #B32646;
    color: #fff;
}

.ticket-claim-form button:hover {
    border-color: #951f3a;
    background: #951f3a;
    color: #fff;
}

.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-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;
}

.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-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;
}

@media (max-width: 760px) {
    .stats,
    .health-grid,
    .grid,
    .summary-grid,
    .settings-form,
    .analytics-filters,
    .payment-filters,
    .client-settings-grid,
    .client-subscription-summary {
        display: block;
    }

    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        align-items: center;
        padding: 10px 14px;
    }

    .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;
    }

    .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%;
    }

    .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 (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
