:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #f7faff;
    --line: #d7e0ee;
    --text: #10213f;
    --muted: #66758f;
    --brand: #1f56b3;
    --brand-dark: #12366f;
    --brand-deep: #11366c;
    --brand-soft: #eaf2ff;
    --brand-ring: #91b9f5;
    --green: #157347;
    --amber: #9a5b00;
    --red: #b42318;
    --shadow: 0 12px 28px rgba(16, 24, 40, .08);
    font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

button,
.primary-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    padding: 0 14px;
    background: var(--brand);
    color: white;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

button:hover,
.primary-link:hover {
    background: var(--brand-dark);
}

.ghost-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    background: white;
    color: var(--text);
    cursor: pointer;
}

.ghost-button:hover {
    background: var(--surface-2);
}

.danger-button {
    border: 1px solid #f2b8b5;
    background: #fff5f4;
    color: var(--red);
}

.danger-button:hover {
    background: #ffe8e6;
}

input,
select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 10px;
    background: white;
    color: var(--text);
}

input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    accent-color: var(--brand);
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

.checkbox-label {
    min-height: 38px;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    align-content: center;
    color: var(--text);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.1;
}

h2 {
    font-size: 18px;
}

small {
    color: var(--muted);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.app-shell.app-shell-login {
    grid-template-columns: minmax(0, 1fr);
}

.sidebar {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
    border-right: 1px solid rgba(255, 255, 255, .14);
    background: var(--brand-deep);
    color: white;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-block span,
.sidebar-meta span {
    display: block;
    color: rgba(255, 255, 255, .62);
    font-size: 12px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 10px;
    object-fit: contain;
    filter: drop-shadow(0 5px 8px rgba(2, 15, 36, .22));
}

.nav-stack {
    display: grid;
    gap: 6px;
}

.nav-link {
    min-height: 38px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    padding: 0 10px;
    color: rgba(255, 255, 255, .78);
}

.nav-link.active,
.nav-link:hover {
    background: rgba(255, 255, 255, .14);
    color: white;
}

.sidebar-meta {
    margin-top: auto;
    display: grid;
    gap: 3px;
    overflow-wrap: anywhere;
}

.main-surface {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(10px);
}

.identity-block {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.page-content {
    padding: 22px;
}

.page-heading,
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.command-group {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.command-group.wrap {
    flex-wrap: wrap;
}

.eyebrow {
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.tenant-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
    box-shadow: var(--shadow);
}

.tenant-hero p {
    margin-top: 7px;
    color: var(--muted);
}

.tenant-actions {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.tenant-action {
    min-width: 132px;
    min-height: 54px;
    display: grid;
    align-content: center;
    gap: 2px;
    border: 1px solid #bdd3f7;
    border-radius: 8px;
    padding: 9px 12px;
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.tenant-action:hover {
    border-color: var(--brand);
    background: #dfeeff;
}

.tenant-action span {
    color: #506b97;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.tenant-action strong {
    color: var(--text);
    font-size: 14px;
    line-height: 1.2;
}

.tenant-action-secondary {
    border-color: var(--brand);
    background: var(--brand);
}

.tenant-action-secondary:hover {
    border-color: var(--brand-dark);
    background: var(--brand-dark);
}

.tenant-action-secondary span,
.tenant-action-secondary strong {
    color: white;
}

.login-shell {
    min-height: calc(100vh - 120px);
    display: grid;
    place-items: center;
}

.login-panel {
    width: min(420px, 100%);
    display: grid;
    gap: 18px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.login-brand img {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    object-fit: contain;
    filter: drop-shadow(0 8px 13px rgba(18, 54, 111, .18));
}

.form-stack,
.form-grid {
    display: grid;
    gap: 12px;
}

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

.form-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 14px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.metric-tile,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-tile {
    display: grid;
    gap: 6px;
    padding: 16px;
}

.metric-tile span {
    color: var(--muted);
    font-size: 13px;
}

.metric-tile strong {
    font-size: 28px;
}

.tenant-metrics .metric-tile {
    min-height: 92px;
}

.tenant-metrics .metric-tile strong {
    font-size: 24px;
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 14px;
}

.tenant-detail-grid {
    display: grid;
    grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.35fr);
    gap: 14px;
    align-items: start;
}

.panel {
    padding: 14px;
}

.dense-list,
.data-table {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.dense-row,
.table-row {
    display: grid;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: white;
    color: var(--text);
    text-align: left;
}

.dense-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.table-row {
    grid-template-columns: minmax(220px, 1.4fr) minmax(130px, .8fr) minmax(130px, .8fr) auto;
    width: 100%;
}

.table-row:last-child,
.dense-row:last-child {
    border-bottom: 0;
}

.table-row:hover,
.dense-row:hover {
    background: var(--surface-2);
}

.table-row span:first-child,
.dense-row span:first-child {
    display: grid;
    gap: 2px;
}

.status-chip {
    width: fit-content;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0 9px;
    background: #eef2f6;
    color: var(--muted);
    font-size: 12px;
}

.warning-chip {
    background: #fff7e6;
    color: var(--amber);
}

.danger-chip {
    background: #fff5f4;
    color: var(--red);
}

.live-chip {
    background: #ecfdf3;
    color: var(--green);
}

.permission-workbench {
    margin-top: 14px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.permission-item {
    grid-template-columns: minmax(0, 1fr) 150px;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    background: white;
}

.permission-item span {
    display: grid;
    gap: 2px;
}

.audit-toolbar {
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) 150px auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 12px;
}

.audit-toolbar > div:first-child {
    display: grid;
    gap: 2px;
    min-width: 110px;
}

.audit-toolbar > div:first-child strong {
    font-size: 28px;
}

.audit-toolbar > div:first-child span {
    color: var(--muted);
    font-size: 13px;
}

.audit-policy {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    border: 1px solid #c8d7f5;
    border-radius: 8px;
    padding: 10px 12px;
    background: #f4f8ff;
    color: #244f91;
}

.audit-policy span {
    color: #48648f;
}

.audit-table .audit-row {
    grid-template-columns: minmax(320px, 1.8fr) minmax(190px, .8fr) minmax(190px, .8fr) minmax(220px, 1fr);
}

.audit-narrative strong,
.audit-narrative small {
    overflow-wrap: anywhere;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    color: var(--muted);
}

.module-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 10px;
}

.module-search small {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    padding-bottom: 10px;
}

.module-card-list {
    display: grid;
    gap: 8px;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.module-card-list::-webkit-scrollbar {
    display: none;
}

.module-card {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(160px, .9fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: white;
}

.module-card.enabled {
    border-color: #bad7c7;
    background: #fbfefc;
}

.module-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.module-main-openable {
    cursor: pointer;
}

.module-main-openable:hover strong {
    color: var(--brand);
}

.module-main span:last-child,
.module-meta,
.tenant-user-row span:first-child {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.module-main strong,
.module-main small,
.tenant-user-row strong,
.tenant-user-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.module-meta {
    justify-items: start;
}

.module-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #c7ced8;
}

.status-dot.on {
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(21, 115, 71, .11);
}

.tenant-user-workbench {
    display: grid;
    grid-template-columns: minmax(260px, .78fr) minmax(360px, 1fr);
    gap: 14px;
    align-items: start;
}

.tenant-user-form {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
}

.two-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.tenant-user-list {
    display: grid;
    gap: 8px;
}

.tenant-user-row {
    width: 100%;
    min-height: 74px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: white;
    color: var(--text);
    text-align: left;
}

.tenant-user-row:hover,
.tenant-user-row.selected {
    border-color: var(--brand-ring);
    background: #f8fbff;
}

.user-row-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.loading-block,
.success-text,
.warning-text,
.error-text {
    padding: 12px;
    border-radius: 6px;
}

.loading-block {
    border: 1px solid var(--line);
    background: white;
    color: var(--muted);
}

.success-text {
    border: 1px solid #b7e4c7;
    background: #effbf3;
    color: var(--green);
    margin-bottom: 12px;
}

.warning-text {
    border: 1px solid #ffd699;
    background: #fff7e6;
    color: var(--amber);
    margin-bottom: 12px;
}

.error-text {
    border: 1px solid #f2b8b5;
    background: #fff5f4;
    color: var(--red);
    margin-bottom: 12px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 150px;
}

.empty-state p,
.empty-inline {
    color: var(--muted);
}

.empty-inline {
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: 6px;
    background: var(--surface-2);
}

.communications-workbench {
    display: grid;
    grid-template-columns: minmax(260px, .85fr) minmax(420px, 1.45fr) minmax(300px, .95fr);
    gap: 14px;
    align-items: start;
}

.communications-metrics {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.compact-head {
    margin-bottom: 10px;
}

.conversation-list-panel,
.conversation-thread-panel,
.operations-panel {
    min-height: 640px;
}

.conversation-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.conversation-row {
    width: 100%;
    min-height: 86px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: white;
    color: var(--text);
    text-align: left;
}

.conversation-row:hover,
.conversation-row.selected {
    border-color: var(--brand-ring);
    background: #f8fbff;
}

.conversation-main,
.conversation-meta,
.webhook-item span,
.diagnostic-item summary span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.conversation-main span,
.conversation-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    justify-items: end;
}

.thread-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.inline-number {
    width: 118px;
}

.message-list {
    height: 480px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #f7f9fc;
}

.message-row {
    display: flex;
}

.message-row.outbound {
    justify-content: flex-end;
}

.message-bubble {
    width: min(78%, 560px);
    display: grid;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: white;
}

.message-row.outbound .message-bubble {
    border-color: #b9cdfa;
    background: #eef4ff;
}

.message-media-preview,
.message-media-player {
    width: 100%;
    max-height: 280px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    object-fit: contain;
}

.media-link {
    color: var(--brand);
    font-size: 13px;
}

.message-meta,
.reaction-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.reaction-row {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px auto;
    gap: 10px;
    align-items: end;
    margin-top: 12px;
}

.composer textarea {
    width: 100%;
    min-height: 84px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    font: inherit;
}

.stacked-form {
    display: grid;
    gap: 10px;
}

.stacked-form textarea {
    width: 100%;
    min-height: 78px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    font: inherit;
}

.diagnostic-list,
.webhook-list {
    display: grid;
    gap: 8px;
    max-height: 275px;
    overflow-y: auto;
}

.compact-list {
    max-height: 180px;
}

.diagnostic-item,
.webhook-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: white;
}

.diagnostic-item summary {
    cursor: pointer;
}

.diagnostic-item p {
    margin-top: 8px;
    color: var(--muted);
}

.diagnostic-item pre {
    max-height: 180px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    background: var(--brand-deep);
    color: white;
    font-size: 12px;
    white-space: pre-wrap;
}

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

.panel-divider {
    height: 1px;
    margin: 14px 0;
    background: var(--line);
}

.instance-form {
    margin-bottom: 0;
}

.add-instance-form {
    margin-bottom: 0;
}

.phone-hint {
    min-height: 34px;
    display: flex;
    align-items: center;
    border: 1px solid #f6d7a8;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff8ed;
    color: var(--amber);
    font-size: 13px;
}

.phone-hint.valid {
    border-color: #b7e4c7;
    background: #f0fdf4;
    color: var(--green);
}

.fixed-settings-panel,
.connection-summary,
.danger-zone,
.polling-status,
.provider-details {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
}

.fixed-settings-panel strong,
.connection-summary strong,
.danger-zone strong {
    display: block;
}

.fixed-settings-panel small,
.connection-summary span,
.danger-zone small {
    color: var(--muted);
    font-size: 13px;
}

.evolution-default-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.evolution-default-badge {
    min-height: 54px;
    display: grid;
    align-content: center;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
}

.evolution-default-badge strong {
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.2;
}

.evolution-default-badge small {
    font-size: 12px;
}

.evolution-default-badge.default-enabled {
    border-color: #b7e4c7;
    background: #f0fdf4;
}

.evolution-default-badge.default-enabled small {
    color: var(--green);
}

.evolution-default-badge.default-disabled {
    border-color: #e4e7ec;
    background: #f8fafc;
}

.evolution-default-badge.default-disabled small {
    color: var(--muted);
}

.evolution-default-badge.default-neutral {
    border-color: #c8d7f5;
    background: #f4f8ff;
}

.evolution-default-badge.default-neutral small {
    color: #48648f;
}

.webhook-address-card {
    display: grid;
    gap: 8px;
    border: 1px solid #d6e3f8;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.webhook-address-card code {
    display: block;
    overflow-wrap: anywhere;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--brand-deep);
    color: #e6f0ff;
    font-size: 12px;
    line-height: 1.5;
}

.groups-panel {
    align-content: start;
}

.group-list {
    display: grid;
    gap: 8px;
}

.group-row {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.group-name-cell {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.group-icon {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid #bfd0e8;
    border-radius: 50%;
    background: #eef5ff;
    color: var(--brand);
}

.group-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.group-row strong,
.group-row span,
.group-row small {
    display: block;
    overflow-wrap: anywhere;
}

.group-row span {
    color: var(--text);
    font-size: 13px;
}

.prompt-settings-panel {
    margin-bottom: 14px;
}

.prompt-editor-layout {
    display: grid;
    grid-template-columns: minmax(260px, .55fr) minmax(0, 1.7fr);
    gap: 16px;
    align-items: start;
}

.prompt-settings-sidebar,
.prompt-editor-main,
.prompt-editor-section {
    display: grid;
    gap: 12px;
}

.runtime-status-grid {
    display: grid;
    gap: 8px;
}

.runtime-status-grid div,
.prompt-help-box,
.prompt-editor-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
}

.runtime-status-grid span,
.prompt-settings-sidebar small,
.prompt-help-box small,
.prompt-editor-section small {
    color: var(--muted);
    font-size: 12px;
}

.runtime-status-grid strong,
.prompt-help-box code {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.runtime-flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.runtime-flow div {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 3px 8px;
    align-items: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: var(--surface-2);
}

.runtime-flow strong,
.runtime-flow small {
    min-width: 0;
    overflow-wrap: anywhere;
}

.runtime-flow small {
    grid-column: 2;
    color: var(--muted);
    font-size: 12px;
}

.prompt-editor-section {
    background: white;
}

.prompt-editor-section-head,
.template-preview-head {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.prompt-editor-section h3 {
    margin: 0;
    font-size: 16px;
}

.template-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    gap: 12px;
    align-items: stretch;
}

.prompt-settings-sidebar label,
.prompt-editor-section label {
    display: grid;
    gap: 6px;
}

.editor-textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    line-height: 1.45;
    tab-size: 2;
}

.classifier-textarea {
    min-height: 260px;
}

.prompt-textarea {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    line-height: 1.45;
    tab-size: 2;
}

.prompt-textarea.tall {
    min-height: 430px;
}

.tool-settings-stack {
    display: grid;
    gap: 16px;
}

.tool-settings-section {
    display: grid;
    gap: 12px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.tool-settings-section:first-child {
    border-top: 0;
    padding-top: 0;
}

.module-inline-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.module-inline-head div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.module-inline-head small {
    color: var(--muted);
}

.template-preview {
    display: grid;
    gap: 8px;
    min-width: 0;
    align-content: start;
    border-left: 3px solid var(--brand);
    padding-left: 12px;
}

.template-preview pre {
    margin: 0;
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
}

.danger-zone {
    border-color: #f2b8b5;
    background: #fffafa;
}

.polling-status {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    border-color: #b9cdfa;
    background: #eef4ff;
    color: var(--brand);
    font-size: 13px;
}

.spinner-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
    background: var(--brand);
    animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%,
    100% {
        opacity: .35;
        transform: scale(.8);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.provider-details summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
}

.command-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.provider-result,
.qr-panel {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
}

.provider-result code,
.qr-panel code {
    display: block;
    overflow-wrap: anywhere;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    background: white;
    color: var(--text);
}

.qr-panel {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
}

.connection-qr-panel {
    background: white;
}

.qr-panel img {
    width: 220px;
    max-width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    object-fit: contain;
}

.json-block {
    max-height: 460px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    background: var(--brand-deep);
    color: white;
    font-size: 12px;
    white-space: pre-wrap;
}

.compact-list {
    gap: 0.65rem;
}

.catalog-product-grid {
    display: grid;
    gap: 0.75rem;
}

.catalog-product-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) minmax(120px, auto);
    gap: 0.9rem;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.catalog-product-row img {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface);
}

.catalog-product-row strong,
.catalog-product-row small,
.catalog-product-row p {
    display: block;
}

.catalog-product-row p {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.83rem;
    line-height: 1.35;
    max-height: 2.8em;
    overflow: hidden;
}

.catalog-product-side {
    display: grid;
    justify-items: end;
    gap: 0.35rem;
    text-align: right;
}

#blazor-error-ui {
    display: none;
}

@media (max-width: 1040px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    .split-grid,
    .tenant-detail-grid,
    .tenant-user-workbench,
    .module-card,
    .prompt-editor-layout,
    .template-editor-grid,
    .runtime-flow,
    .audit-toolbar,
    .communications-workbench,
    .metric-grid,
    .permission-grid,
    .form-grid,
    .form-grid.compact,
    .two-field-grid,
    .table-row,
    .composer,
    .conversation-row,
    .group-row,
    .webhook-item,
    .audit-table .audit-row,
    .qr-panel {
        grid-template-columns: 1fr;
    }

    .catalog-product-row {
        grid-template-columns: 56px minmax(0, 1fr);
    }

    .catalog-product-row img {
        width: 56px;
        height: 56px;
    }

    .catalog-product-side {
        grid-column: 1 / -1;
        justify-items: start;
        text-align: left;
    }

    .audit-policy,
    .pagination-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .tenant-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .tenant-actions {
        justify-content: stretch;
    }

    .tenant-action {
        flex: 1 1 150px;
    }

    .module-search {
        grid-template-columns: 1fr;
    }

    .module-search small {
        padding-bottom: 0;
    }

    .tenant-user-row {
        grid-template-columns: 1fr;
    }

    .user-row-meta {
        justify-content: flex-start;
    }

    .module-actions {
        justify-content: flex-start;
        justify-items: start;
    }

    .conversation-list-panel,
    .conversation-thread-panel,
    .operations-panel {
        min-height: auto;
    }

    .message-list {
        height: 420px;
    }

    .message-bubble {
        width: 100%;
    }
}
