
html {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(255,255,255,0.08);
}
html::-webkit-scrollbar {
    width: 8px;
}
html::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.06);
}
html::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 999px;
}
html::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* ./adm/css/styles.css */
/* Adopt Cluster365 landing theme tokens while keeping existing var names */
:root {
    /* Primary/action color (use landing accent2 purple) */
    --primary-color: #8B5CF6;
    --primary-hover: #7C3AED;
    /* Dark theme background + cards from landing page */
    --background-color: #0b0d12; /* maps to --bg */
    --card-background: #11151f;  /* maps to --card */
    --text-color: #e8eef9;       /* maps to --txt */
    --muted-color: #9aa3b2;      /* maps to --muted */
    --error-color: #ef4444;
    /* Extra accents (not widely used, but available) */
    --accent1: #6EE7F9;
    --accent2: #8B5CF6;
    --accent3: #F43F5E;
    --ring: rgba(110,231,249,.6);
}

/* Action buttons layout: 2 per row, full-width */
.action-cell {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: center;
    white-space: nowrap;
}
.action-cell button {
    flex: 0 0 auto;
    width: auto;
}
.tool-row td {
    border-bottom: none;
    vertical-align: middle;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
    /* Landing background: two radial accents over dark base */
    background: radial-gradient(1200px 600px at 10% -10%, rgba(139,92,246,.35), transparent 55%),
                radial-gradient(1000px 600px at 90% 10%, rgba(244,63,94,.28), transparent 55%),
                var(--background-color);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    color: var(--text-color);
    line-height: 1.5;
}

/* Layout helpers for sticky footer */
html, body { height: 100%; }
body { display: flex; flex-direction: column; }
.main-content {
    /* Comment: Avoid flex-grow here.
       On the dashboard, shrinking the bot grid (via search) can trigger a layout reflow that makes the header/search/cards
       appear to "drop" down the page. Keeping main content sized to its actual content avoids that reflow.
       The footer is kept at the bottom via margin-top:auto instead. */
    flex: 0 0 auto;
}
.site-footer {
    /* Comment: Sticky footer without forcing main content to grow. */
    margin-top: auto;
    padding: 0.75rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: var(--muted-color);
}
.site-footer a { color: #cfd6e6; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06) inset;
    width: 100%;
    max-width: 400px;
}

.hidden { display: none !important; }

.alert {
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fecaca;
}

.alert-info {
    background: rgba(110, 231, 249, 0.12);
    border: 1px solid rgba(110, 231, 249, 0.35);
    color: #a5f3fc;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-size: 1.5rem;
}

body.adm-login-page {
    --primary-color: #793bf2;
    --primary-hover: #8a52f5;
    --background-color: #0a0616;
    --card-background: #120e1e;
    --text-color: #eadff0;
    --muted-color: #6c7280;
    --ring: rgba(121, 59, 242, 0.32);
    background: #0a0616;
    color: var(--text-color);
}

.adm-login-page .login-container {
    min-height: 100vh;
    padding: 24px;
    display: grid;
    place-items: center;
}

.adm-login-page .login-card {
    width: min(420px, 100%);
    max-width: 420px;
    padding: 28px;
    border: 1px solid #1d1a29;
    border-radius: 16px;
    background: #120e1e;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.adm-login-page .login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

.adm-login-page .login-brand img {
    width: 44px;
    height: 44px;
    display: block;
}

.adm-login-page .login-brand span {
    color: #eadff0;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.adm-login-page .login-card h1 {
    margin: 0 0 18px;
    color: #eadff0;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 800;
    text-align: center;
}

.adm-login-page .oauth-button {
    min-height: 42px;
    border: 1px solid #1d1a29;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: none;
}

.adm-login-page .oauth-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.adm-login-page .divider {
    gap: 10px;
    margin: 16px 0;
    text-transform: none;
    letter-spacing: 0;
    color: #6c7280;
    font-size: 13px;
}

.adm-login-page .divider::before,
.adm-login-page .divider::after {
    background: #1d1a29;
}

.adm-login-page .divider span {
    margin: 0;
}

.adm-login-page .helper-text {
    margin: 0 0 16px;
    color: #6c7280;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.adm-login-page .form-group {
    margin-bottom: 14px;
}

.adm-login-page .form-group label {
    margin-bottom: 7px;
    color: #eadff0;
    font-size: 13px;
    font-weight: 600;
}

.adm-login-page .form-group input:not([type="checkbox"]):not([type="radio"]) {
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #1d1a29;
    border-radius: 10px;
    background: #0a0616;
    color: #eadff0;
    font-size: 14px;
}

.adm-login-page .form-group input:not([type="checkbox"]):not([type="radio"])::placeholder {
    color: #555b69;
}

.adm-login-page .form-group input:not([type="checkbox"]):not([type="radio"]):focus {
    border-color: #793bf2;
    box-shadow: 0 0 0 3px rgba(121, 59, 242, 0.18);
}

.adm-login-page .form-hint {
    color: #6c7280;
    font-size: 12px;
    line-height: 1.45;
}

.adm-login-page .auth-actions {
    gap: 10px;
    margin-top: 16px;
}

.adm-login-page .btn-primary {
    min-height: 42px;
    border-radius: 10px;
    background: #793bf2;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.adm-login-page .btn-primary:hover {
    background: #8a52f5;
}

.adm-login-page .btn-secondary {
    min-height: 42px;
    border: 1px solid #1d1a29;
    border-radius: 10px;
    background: transparent;
    color: #eadff0;
    font-size: 14px;
    font-weight: 700;
}

.adm-login-page .btn-secondary:hover {
    border-color: #793bf2;
    background: rgba(121, 59, 242, 0.15);
}

.adm-login-page .alert {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.adm-login-page .alert-error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.32);
    color: #fecaca;
}

.adm-login-page .alert-info {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.32);
    color: #bfdbfe;
}

.adm-login-page .login-consent {
    margin-top: 12px;
    margin-bottom: 0;
    font-size: 12px;
}

.adm-login-page .login-consent a {
    color: #eadff0;
    text-decoration: underline;
}

.adm-login-page .auth-help-link,
.c365-auth-page .auth-help-link,
.c365-auth-page .c365-auth-link,
.c365-auth-page .c365-auth-inline-link {
    color: #c4b5fd;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.adm-login-page .auth-help-link,
.c365-auth-page .auth-help-link,
.c365-auth-page .c365-auth-link {
    border-bottom: 1px solid rgba(196, 181, 253, 0.42);
}

.adm-login-page .auth-help-link:hover,
.c365-auth-page .auth-help-link:hover,
.c365-auth-page .c365-auth-link:hover,
.c365-auth-page .c365-auth-inline-link:hover {
    border-color: #ddd6fe;
    color: #ddd6fe;
}

body.c365-auth-page {
    --primary-color: #793bf2;
    --primary-hover: #8a52f5;
    --background-color: #0a0616;
    --card-background: #120e1e;
    --text-color: #eadff0;
    --muted-color: #9aa3b2;
    background: #0a0616;
    color: var(--text-color);
}

.c365-auth-page .login-container {
    min-height: 100vh;
    padding: 24px;
    display: grid;
    place-items: center;
}

.c365-auth-page .login-card {
    width: min(420px, 100%);
    max-width: 420px;
    padding: 28px;
    border: 1px solid #1d1a29;
    border-radius: 16px;
    background: #120e1e;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.c365-auth-page .login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

.c365-auth-page .login-brand img {
    width: 44px;
    height: 44px;
    display: block;
}

.c365-auth-page .login-brand span {
    color: #eadff0;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.c365-auth-page .login-card h1 {
    margin: 0 0 12px;
    color: #eadff0;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 800;
    text-align: center;
}

.c365-auth-page .helper-text,
.c365-auth-page .client-label {
    margin: 0 0 16px;
    color: #9aa3b2;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.c365-auth-page .client-label strong {
    color: #eadff0;
    font-weight: 700;
}

.c365-auth-page .form-group {
    margin-bottom: 14px;
}

.c365-auth-page .form-group label {
    margin-bottom: 7px;
    color: #eadff0;
    font-size: 13px;
    font-weight: 600;
}

.c365-auth-page .form-group input:not([type="checkbox"]):not([type="radio"]) {
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #1d1a29;
    border-radius: 10px;
    background: #0a0616;
    color: #eadff0;
    font-size: 14px;
}

.c365-auth-page .form-group input:not([type="checkbox"]):not([type="radio"]):focus {
    border-color: #793bf2;
    box-shadow: 0 0 0 3px rgba(121, 59, 242, 0.18);
}

.c365-auth-page .form-hint {
    color: #9aa3b2;
    font-size: 12px;
    line-height: 1.45;
}

.c365-auth-page .login-check-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 10px 0 0;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
}

.c365-auth-page .login-check-row input {
    width: 16px;
    height: 16px;
    margin-top: 1px;
    accent-color: #793bf2;
    flex: 0 0 auto;
}

.c365-auth-page .auth-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.c365-auth-page .btn-primary {
    min-height: 42px;
    border-radius: 10px;
    background: #793bf2;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.c365-auth-page .btn-primary:hover {
    background: #8a52f5;
}

.c365-auth-page .btn-secondary {
    min-height: 42px;
    border: 1px solid rgba(121, 59, 242, 0.34);
    border-radius: 10px;
    background: transparent;
    color: #eadff0;
    font-size: 14px;
    font-weight: 700;
}

.c365-auth-page .btn-secondary:hover {
    border-color: rgba(110, 231, 249, 0.52);
    background: rgba(121, 59, 242, 0.15);
}

.c365-auth-page .oauth-button {
    min-height: 42px;
    border: 1px solid rgba(121, 59, 242, 0.38);
    border-radius: 10px;
    background: #171225;
    color: #eadff0;
    margin-bottom: 0;
    text-decoration: none;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

.c365-auth-page .oauth-button:hover {
    border-color: rgba(110, 231, 249, 0.52);
    background: #1c1730;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.34);
}

.c365-auth-page .c365-google-button {
    justify-content: center;
}

.c365-auth-page .account-selection-form {
    margin-top: 2px;
}

.c365-auth-page .account-selection-list {
    display: grid;
    gap: 10px;
}

.c365-auth-page .account-selection-button {
    width: 100%;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(121, 59, 242, 0.34);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(23, 18, 37, 0.96), rgba(11, 7, 24, 0.96));
    color: #eadff0;
    cursor: pointer;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 12px 30px rgba(0, 0, 0, 0.24);
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.c365-auth-page .account-selection-button:hover,
.c365-auth-page .account-selection-button:focus-visible {
    border-color: rgba(110, 231, 249, 0.62);
    background: linear-gradient(135deg, rgba(32, 25, 53, 0.98), rgba(15, 10, 33, 0.98));
    box-shadow: 0 0 0 3px rgba(110, 231, 249, 0.14), 0 18px 46px rgba(0, 0, 0, 0.36);
    outline: none;
    transform: translateY(-1px);
}

.c365-auth-page .account-selection-text {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.c365-auth-page .account-selection-title {
    display: block;
    color: #f4ecff;
    font-size: 16px;
    line-height: 1.25;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.c365-auth-page .account-selection-meta {
    color: #aeb7c9;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.c365-auth-page .divider {
    gap: 10px;
    margin: 16px 0;
    text-transform: none;
    letter-spacing: 0;
    color: #9aa3b2;
    font-size: 13px;
}

.c365-auth-page .divider::before,
.c365-auth-page .divider::after {
    background: #1d1a29;
}

.c365-auth-page .c365-auth-link-row,
.c365-auth-page .reset-actions {
    margin-top: 14px;
    text-align: center;
}

.c365-auth-page .reset-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.c365-auth-page .alert {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.c365-auth-page .alert-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.34);
    color: #bbf7d0;
}

.c365-auth-page .alert-error {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.32);
    color: #fecaca;
}

.c365-auth-page .alert-info {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.32);
    color: #bfdbfe;
}

.c365-auth-page .login-consent {
    margin-top: 12px;
    margin-bottom: 0;
    font-size: 12px;
}

.c365-auth-page .login-consent a {
    color: #ddd6fe;
    text-decoration: underline;
}

.c365-auth-page .cookie-consent-banner {
    position: fixed;
    left: 24px;
    right: 24px;
    bottom: 24px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    max-width: 860px;
    margin: 0 auto;
    padding: 16px;
    border: 1px solid rgba(110, 231, 249, 0.28);
    border-radius: 12px;
    background: rgba(18, 14, 30, 0.98);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.46);
}

.c365-auth-page .cookie-consent-banner.is-hidden,
.c365-auth-page .cookie-consent-warning.is-hidden {
    display: none;
}

.c365-auth-page .cookie-consent-banner strong {
    display: block;
    color: #f4ecff;
    font-size: 14px;
    margin-bottom: 5px;
}

.c365-auth-page .cookie-consent-banner p {
    margin: 0;
    color: #b8c2d6;
    font-size: 13px;
    line-height: 1.45;
}

.c365-auth-page .cookie-consent-warning {
    margin-top: 7px !important;
    color: #fecaca !important;
}

.c365-auth-page .cookie-consent-actions {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
}

@media (max-width: 640px) {
    .c365-auth-page .cookie-consent-banner {
        left: 12px;
        right: 12px;
        bottom: 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .c365-auth-page .cookie-consent-actions {
        justify-content: stretch;
    }

    .c365-auth-page .cookie-consent-actions .btn {
        flex: 1 1 0;
    }
}

/* Authentication-only RTL support. Technical values and credentials remain
   LTR so email addresses, codes, and passwords cannot be visually reordered. */
html[dir="rtl"] .adm-login-page .login-card,
html[dir="rtl"] .c365-auth-page .login-card { text-align: right; }
html[dir="rtl"] .adm-login-page .form-group label,
html[dir="rtl"] .c365-auth-page .form-group label,
html[dir="rtl"] .adm-login-page .alert,
html[dir="rtl"] .c365-auth-page .alert { text-align: right; }
html[dir="rtl"] .adm-login-page input[type="email"],
html[dir="rtl"] .adm-login-page input[type="password"],
html[dir="rtl"] .adm-login-page input[inputmode="numeric"],
html[dir="rtl"] .c365-auth-page input[type="email"],
html[dir="rtl"] .c365-auth-page input[type="password"],
html[dir="rtl"] .c365-auth-page input[inputmode="numeric"] { direction: ltr; text-align: left; }
html[dir="rtl"] .adm-login-page .form-hint,
html[dir="rtl"] .c365-auth-page .form-hint { text-align: right; }

.oauth-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: #ffffff;
    color: #111827;
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.98rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.oauth-button img {
    width: 18px;
    height: 18px;
}

.oauth-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.divider {
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    color: var(--muted-color);
    margin: 1.25rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
}

.divider span {
    margin: 0 0.75rem;
}

.helper-text {
    font-size: 0.9rem;
    color: var(--muted-color);
    margin-bottom: 0.75rem;
}

/* Diagnostics */
.diagnostic-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    background: rgba(17, 21, 31, 0.6);
}

/* LLM Integrations table: keep Rate column readable (avoid truncation). */
#llmTable th:first-child,
#llmTable td:first-child {
    width: 110px;
    min-width: 110px;
    white-space: nowrap;
}
.diagnostic-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}
.diagnostic-filter-inline {
    min-width: 160px;
    justify-content: flex-end;
}
.diagnostic-filter-actions {
    min-width: 160px;
    align-items: flex-end;
}
.diagnostic-checkbox {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--muted-color);
    font-size: 0.95rem;
    user-select: none;
}
.diagnostic-checkbox input {
    transform: translateY(1px);
}
.diagnostic-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    color: var(--muted-color);
    font-size: 0.95rem;
}
.diagnostic-pill {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.18);
}
.diagnostic-pill strong {
    color: var(--text-color);
}
.diagnostic-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.diagnostic-item {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    gap: 12px;
    padding: 12px 12px 12px 0;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(17, 21, 31, 0.8);
    overflow: hidden;
}
.diagnostic-item-bar {
    background: rgba(255,255,255,0.12);
}
.diagnostic-item[data-type="llm"] .diagnostic-item-bar { background: rgba(244, 63, 94, 0.75); }
.diagnostic-item[data-type="tool"] .diagnostic-item-bar { background: rgba(110, 231, 249, 0.7); }
.diagnostic-item[data-type="guard"] .diagnostic-item-bar { background: rgba(245, 158, 11, 0.75); }
.diagnostic-item[data-type="middleware"] .diagnostic-item-bar { background: rgba(139, 92, 246, 0.75); }
.diagnostic-item-main {
    padding-right: 6px;
}
.diagnostic-item-top {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
    margin-bottom: 6px;
}
.diagnostic-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.18);
    color: var(--text-color);
}
.diagnostic-meta {
    color: var(--muted-color);
    font-size: 0.9rem;
}
.diagnostic-title {
    font-weight: 700;
    color: var(--text-color);
    font-size: 1rem;
    margin-bottom: 6px;
}
.diagnostic-message {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.88rem;
    color: #cfd6e6;
    background: rgba(0,0,0,0.18);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}
.diagnostic-actions {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 12px 12px 12px 0;
}
.diagnostic-actions .btn {
    white-space: nowrap;
}

.auth-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-top: 1rem;
}

.auth-actions .btn-primary {
    flex: 1;
}

.auth-actions .btn-secondary {
    flex: 0 0 auto;
}

.owner-row {
    background: rgba(139, 92, 246, 0.12);
}
.owner-row td {
    font-weight: 600;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--ring);
}

.setting-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}
.setting-row .setting-name,
.setting-row .setting-value {
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 0.95rem;
    padding: 0.5rem;
}
.setting-row .setting-name {
    flex: 0 0 220px;
    max-width: 220px;
}
.setting-row .setting-name:focus,
.setting-row .setting-value:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--ring);
}
.setting-row .setting-value {
    flex: 1;
    min-height: 80px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    line-height: 1.4;
}
.setting-row .btn {
    align-self: flex-start;
}

#botLlmFallbackList {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

#botLlmFallbackList .llm-fallback-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#botLlmFallbackList .llm-fallback-row select {
    flex: 1;
    min-width: 220px;
}

#botLlmFallbackList .llm-fallback-actions {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: nowrap;
}

#botLlmFallbackList .llm-fallback-actions .btn {
    padding: 0.35rem 0.55rem;
    line-height: 1.1;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-inline input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkbox-inline label {
    margin: 0;
}

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.template-select-group {
    margin-top: 1rem;
}
.template-select-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.35rem 0;
}
.template-select-actions select {
    min-width: 220px;
}
.channel-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.channel-row:last-child {
    border-bottom: none;
}
.channel-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
}
.channel-checkbox {
    width: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-shrink: 0;
    padding-top: 2px;
}
.channel-checkbox input {
    margin: 0;
}
.channel-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    line-height: 1.3;
}
.channel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.channel-name {
    font-weight: 600;
}
.channel-desc {
    color: var(--muted-color);
    font-size: 0.85rem;
}
.channel-actions .btn {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}
.google-chat-guide-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.google-chat-guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.85rem;
}
.google-chat-guide-card {
    min-width: 0;
    padding: 0.85rem;
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
}
.google-chat-guide-card.full {
    grid-column: 1 / -1;
}
.google-chat-guide-card h3 {
    margin: 0 0 0.55rem;
}
.google-chat-guide-card ol,
.google-chat-guide-card ul {
    margin: 0;
    padding-left: 1.1rem;
}
.google-chat-guide-card li {
    margin-bottom: 0.4rem;
}
.google-chat-guide-card a {
    color: var(--accent1);
    font-weight: 600;
    text-decoration-color: rgba(110, 231, 249, 0.45);
    text-underline-offset: 3px;
}
.google-chat-guide-card a:hover {
    color: var(--text-color);
    text-decoration-color: var(--accent1);
}
.adm-guide-toast-container {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.adm-guide-toast {
    max-width: 360px;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.24);
    font-size: 13px;
    font-weight: 600;
}
.adm-guide-toast.is-error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}
.channel-rights {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 140px;
}

.channel-rights .rights-summary {
    margin-right: 0;
    font-size: 0.85rem;
    color: var(--muted-color);
    text-align: right;
}
.channel-env-table td input {
    width: 100%;
}
.channel-admin-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.channel-env-actions button {
    margin-left: 0.25rem;
}

#channelEnvModal {
    z-index: 1100;
}
.phone-call-setup-modal {
    z-index: 1120;
}
.phone-call-setup-modal .modal-content {
    max-width: 920px;
}
.phone-call-setup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.phone-call-setup-card {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0.5rem;
    padding: 1rem;
    background: rgba(255,255,255,0.03);
}
.phone-call-setup-card h3 {
    margin-top: 0;
}
.phone-call-setup-card ol,
.phone-call-setup-list {
    margin: 0.75rem 0;
    padding-left: 1.25rem;
}
.phone-call-setup-label {
    display: block;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}
.phone-call-setup-copy-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.phone-call-setup-copy-row input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.phone-call-setup-warning {
    border-left: 3px solid #f59e0b;
    padding: 0.6rem 0.75rem;
    background: rgba(245,158,11,0.12);
    color: var(--text-color);
}
@media (max-width: 760px) {
    .phone-call-setup-grid {
        grid-template-columns: 1fr;
    }
    .phone-call-setup-copy-row {
        align-items: stretch;
        flex-direction: column;
    }
}
.channel-highlight {
    animation: channelPulse 1.6s ease-out;
    border-radius: 0.5rem;
}
@keyframes channelPulse {
    0% { box-shadow: 0 0 0 0 rgba(139,92,246,0.4); }
    100% { box-shadow: 0 0 0 12px rgba(139,92,246,0); }
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }

    .memory-actions {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }

    .memory-actions .form-select {
        max-width: none;
        width: 100%;
    }

    .memory-action-buttons {
        width: 100%;
        justify-content: center;
        justify-self: stretch;
    }

    .memory-action-buttons .btn {
        flex: 1 1 48%;
        min-width: 0;
    }

    .trait-form .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .trait-form .form-actions .form-select {
        max-width: none;
        width: 100%;
    }

    .trait-form .form-actions .btn {
        width: 100%;
    }

    .bot-nav-btn {
        flex: 1 1 calc(50% - 0.5rem);
        text-align: center;
    }
}
/* Overlay for schedule run in progress */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}
.modal-overlay .overlay-message {
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    text-align: center;
}

/* Dashboard Layout */
.admin-header {
    /* Keep the Cluster365 Dashboard header visible while scrolling/filtering long agent lists. */
    background: var(--card-background);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.35), 0 0 0 1px rgba(255,255,255,.06) inset;
    padding: 1rem 0;
    margin-bottom: 1.25rem;
}

/* Keep dashboard header title white */
.admin-header h1 { color: var(--text-color); }

/* Help page section titles only */
.help-page h2 { color: var(--primary-color); }

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Plans tab toolbar: keep "New Plan" + "Starter Pack" side-by-side.
   Note: `.btn-primary` is globally `width:100%`, so we override inside this toolbar. */
.plans-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.plans-toolbar-actions .btn {
    width: auto;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    line-height: 1.1;
}

/* Admin header actions: prevent oversized buttons from overflowing on mid-size screens.
   Desktop/tablet: wrap to a second line when needed.
   Mobile: keep horizontal scroll (see media query below). */
.admin-header .header-actions {
    flex-wrap: wrap;
    row-gap: 0.75rem;
    align-items: center;
    justify-content: flex-start;
}
.admin-header .header-actions .btn {
    width: auto; /* override `.btn-primary { width:100%; }` for header actions */
    white-space: nowrap;
    display: inline-flex; /* normalize <a> vs <button> box model */
    align-items: center;  /* consistent vertical centering */
    line-height: 1.1;     /* avoid inheriting body (1.5) on <a> */
}
@media (max-width: 1100px) {
    .admin-header .header-actions {
        gap: 0.6rem;
        row-gap: 0.6rem;
    }
    .admin-header .header-actions .btn {
        padding: 0.45rem 0.8rem;
        font-size: 0.95rem;
    }
}
.form-hint {
    margin-top: 0.35rem;
    color: var(--muted-color);
    font-size: 0.9rem;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-accent-purple {
    background-color: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

.btn-accent-purple:hover,
.btn-accent-purple:focus {
    background-color: #6d28d9;
    border-color: #6d28d9;
    color: #fff;
}

.header-actions, .modal-body, .modal-content {
    scrollbar-width: auto;
    scrollbar-color: #9333ea rgba(255,255,255,0.18);
}
.header-actions::-webkit-scrollbar, .modal-body::-webkit-scrollbar, .modal-content::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}
.header-actions::-webkit-scrollbar-track, .modal-body::-webkit-scrollbar-track, .modal-content::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.12);
}
.header-actions::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb, .modal-content::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
    border-radius: 999px;
}
.header-actions::-webkit-scrollbar-thumb:hover, .modal-body::-webkit-scrollbar-thumb:hover, .modal-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #c084fc, #8b5cf6);
}

@media (max-width: 768px) {
    .modal-large {
        max-width: 95%;
    }
    .modal-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-body > table,
    .modal-body .table {
        min-width: 640px;
    }
    /* Bot card dropdowns: on mobile, anchor menus to the left so labels don't clip off-screen. */
    .bot-comm-menu,
    .bot-memory-menu {
        left: 0;
        right: auto;
        max-width: calc(100vw - 24px);
        box-sizing: border-box;
    }
    /* Bot Files modal: render files as stacked cards on mobile (JS switches rendering). */
    .bot-files-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .bot-files-card {
        border: 1px solid rgba(255,255,255,0.12);
        background: rgba(255,255,255,0.04);
        border-radius: 10px;
        padding: 10px 12px;
    }
    .bot-files-card-title {
        font-weight: 600;
        font-size: 14px;
        line-height: 1.25;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    .bot-files-card-meta {
        margin-top: 3px;
        font-size: 12px;
        color: var(--muted-color);
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    .bot-files-card-actions {
        margin-top: 10px;
        justify-content: flex-end;
    }
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    /* Mobile: keep the Admin header action buttons on one scrollable row.
       IMPORTANT: Must match `.admin-header .header-actions` specificity or desktop `flex-wrap: wrap` wins. */
    .admin-header .header-actions {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap; /* keep single row + scroll on mobile */
        gap: 0.75rem;
        padding: 0 0 0.5rem 0;
        row-gap: 0;
    }
    .header-actions::-webkit-scrollbar {
        display: none;
    }
    .header-actions > * {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}


/* In header actions, use primary styling for secondary buttons to match "New Agent" */
.admin-header .header-actions .btn-secondary {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.admin-header .header-actions .btn-secondary:hover {
    background-color: var(--primary-hover);
}

/* LLM modal: make "Distribute to Clients" secondary button primary-styled */
.llm-actions .btn-secondary {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.llm-actions .btn-secondary:hover {
    background-color: var(--primary-hover);
}

#llmUsageCard {
    overflow: visible;
}

/* Contextual button coloring by action (attribute selectors keep logic untouched) */
/* Cancel buttons: reddish */
.btn[onclick*="cancel"],
.btn[onclick*="closeModal"] {
    background-color: var(--accent3);
    color: #ffffff;
    border: none;
}
.btn[onclick*="cancel"]:hover,
.btn[onclick*="closeModal"]:hover {
    background-color: #e11d48; /* darker red */
}

/* Edit buttons: purple */
.btn[onclick^="edit"],
.btn[onclick*="edit("] {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.btn[onclick^="edit"]:hover,
.btn[onclick*="edit("]:hover {
    background-color: var(--primary-hover);
}
/* Icon edit button in bot cards */
.btn-icon[onclick^="edit"],
.btn-icon[title*="Edit"] {
    color: var(--primary-color);
}
.btn-icon[onclick^="edit"]:hover,
.btn-icon[title*="Edit"]:hover {
    background-color: rgba(139,92,246,0.15);
}

/* Delete buttons: reddish (text/icon); retain .btn-danger where used) */
.btn-icon[onclick^="delete"],
.btn-icon.delete-bot {
    background-color: var(--accent3);
    color: #ffffff !important;
}
.btn-icon[onclick^="delete"]:hover,
.btn-icon.delete-bot:hover {
    background-color: #e11d48;
}
.btn.btn-danger { background-color: var(--accent3); border: none; color: #fff; }
.btn.btn-danger:hover { background-color: #e11d48; }

/* Link-styled delete buttons should also be filled red like Cancel */
.btn.text-danger {
    background-color: var(--accent3);
    color: #ffffff !important;
    border: none;
}
.btn.text-danger:hover { background-color: #e11d48; }

/* Add row buttons: purple */
.btn[onclick^="addSettingRow"],
.btn[onclick^="addPrePromptRow"],
.btn[onclick^="addToolRow"],
.btn[onclick^="addBotGuardRow"],
.btn[onclick^="addBotMiddlewareRow"],
.btn[onclick^="addMcpConnectorRow"] {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
}
.btn[onclick^="addSettingRow"]:hover,
.btn[onclick^="addPrePromptRow"]:hover,
.btn[onclick^="addToolRow"]:hover,
.btn[onclick^="addBotGuardRow"]:hover,
.btn[onclick^="addBotMiddlewareRow"]:hover,
.btn[onclick^="addMcpConnectorRow"]:hover {
    background-color: var(--primary-hover);
}

/* Clients table: make Copy Resources and Login as purple like primary */
.btn[onclick^="openSeedResources"],
.btn[onclick^="impersonateClient"] {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border: none;
    text-decoration: none;
}
.btn[onclick^="openSeedResources"]:hover,
.btn[onclick^="impersonateClient"]:hover {
    background-color: var(--primary-hover);
}

/* Schedules: View Logs and Run Now buttons in purple */
.btn[onclick^="viewScheduleLogs"],
.btn[onclick^="runSchedule"] {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border: none;
}
.btn[onclick^="viewScheduleLogs"]:hover,
.btn[onclick^="runSchedule"]:hover {
    background-color: var(--primary-hover);
}

/* Events: make "API Docs" button purple and same visual weight as New Event */
.schedule-actions .btn[onclick^="showEventApiDocs"] {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border: none;
}
.schedule-actions .btn[onclick^="showEventApiDocs"]:hover {
    background-color: var(--primary-hover);
}
/* In Events modal, stack buttons with spacing and equal width like Tools */
#eventsModal .schedule-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#eventsModal .schedule-actions .btn {
    width: 100%;
}
#eventsModal #eventSpecificToolsWrapper > label {
    color: var(--text-color);
}
#eventsModal #eventSpecificTools {
    background: #1f2937 !important;
    border-color: #334155 !important;
    color: #f8fafc;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
#eventsModal #eventSpecificTools label {
    color: #f8fafc;
}
#eventsModal #eventSpecificTools small {
    color: #cbd5e1 !important;
    opacity: 1 !important;
}
#eventsModal #eventSpecificTools input[type="checkbox"] {
    accent-color: var(--primary-color);
}
#eventsModal #eventSpecificTools .no-data {
    color: #cbd5e1;
}

/* Bot Grid */
.bot-search-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 0.25rem 0 0.5rem 0;
    flex-wrap: wrap;
}

.bot-search-row .tool-search {
    flex: 1 1 320px;
}

.bot-search-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: var(--text-color);
}

.bot-search-meta {
    flex: 0 0 auto;
    min-width: 140px;
    text-align: right;
    color: var(--muted-color);
}

.bot-search-row #botSearchClearAll[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.bot-search-clearx {
    padding: 0.5rem 0.65rem;
    min-width: 44px;
}
.bot-search-clearx i {
    pointer-events: none;
}

.bot-tag-filter-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 46vh;
    overflow: auto;
    padding-right: 4px;
}
.bot-tag-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
    cursor: pointer;
    user-select: none;
}
.bot-tag-filter-row:hover {
    background: rgba(255,255,255,.05);
}
.bot-tag-filter-row input[type="checkbox"] {
    transform: scale(1.05);
}
.bot-tag-filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 0.85rem;
    line-height: 1;
    box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset;
}
.bot-tag-filter-scope {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.bot-card {
    background: var(--card-background);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06) inset;
    /* Allow dropdown menus (chat/memories) to escape the card bounds. */
    overflow: visible;
}

.bot-card-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.bot-header-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.bot-header-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.bot-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    object-fit: cover;
    flex: 0 0 34px;
    box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset;
}

.bot-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.18);
    color: #e5e7eb;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    user-select: none;
}

.bot-card-header h2 {
    margin: 0;
    font-size: 1.25rem;
    min-width: 0;
}

.bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-start;
}

/* Bot modal: avatar editor (right of Name/Title on desktop, stacked on mobile). */
.bot-name-avatar-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.bot-name-fields {
    flex: 1 1 auto;
    min-width: 0;
}

.bot-avatar-editor {
    flex: 0 0 320px;
    max-width: 360px;
}

.bot-avatar-editor-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.bot-avatar-preview-wrap {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    background: rgba(15,23,42,0.55);
    box-shadow: 0 0 0 1px rgba(255,255,255,.10) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 72px;
}

.bot-avatar-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bot-avatar-preview-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5e7eb;
    font-weight: 800;
    font-size: 1.4rem;
    background: rgba(99,102,241,0.18);
}

.bot-avatar-controls {
    flex: 1 1 auto;
    min-width: 0;
}

.bot-avatar-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.bot-avatar-icon-btn {
    padding: 6px 8px;
    min-width: 36px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Bot modal: skills rows - prevent long skill names from forcing horizontal scroll. */
.bot-skill-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.bot-skill-row .bot-skill-code {
    flex: 1 1 420px;
    min-width: 240px;
    max-width: 100%;
}
.bot-skill-row select.bot-skill-code {
    width: 100%;
    min-width: 0;
}

@media (max-width: 720px) {
    .bot-name-avatar-row {
        flex-direction: column;
    }
    .bot-avatar-editor {
        flex: 1 1 auto;
        max-width: 100%;
    }
}

.bot-comm-wrapper,
.bot-memory-wrapper {
    position: relative;
}

.comm-caret,
.memory-caret {
    font-size: 0.6rem;
    margin-left: 0.3rem;
}

.bot-comm-menu,
.bot-memory-menu {
    position: absolute;
    top: 110%;
    right: 0;
    display: none;
    min-width: 180px;
    background: rgba(17,24,39,0.95);
    border: 1px solid rgba(139,92,246,0.25);
    border-radius: 0.6rem;
    box-shadow: 0 12px 32px rgba(8,11,21,0.45);
    padding: 0.4rem 0.35rem;
    z-index: 100;
    backdrop-filter: blur(6px);
}

.bot-comm-menu[aria-hidden="false"],
.bot-memory-menu[aria-hidden="false"] {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bot-comm-menu button,
.bot-memory-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    border: none;
    background: transparent;
    color: rgba(232,238,249,0.9);
    font-size: 0.85rem;
    padding: 0.4rem 0.5rem;
    border-radius: 0.45rem;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.bot-comm-menu button i,
.bot-memory-menu button i {
    width: 1rem;
    text-align: center;
}

.bot-comm-menu button:hover,
.bot-memory-menu button:hover {
    background: rgba(139,92,246,0.18);
    color: #ffffff;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.35rem;
    cursor: pointer;
    color: var(--text-color);
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(255,255,255,0.06);
}

.delete-bot {
    color: var(--error-color);
}

.bot-card-body {
    padding: 1rem;
}

@media (min-width: 768px) {
    .bot-header-content {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .bot-header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .bot-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

.bot-title {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.bot-description {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

/* Make modal-content a positioning context for overlay */
.modal-content {
    position: relative;
    background: var(--card-background);
    margin: 2rem auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    border-radius: 0.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06) inset;
    /* allow vertical scrolling if content overflows */
    max-height: 80vh;
    overflow-y: auto;
    /* permit horizontal panning when tables overflow on mobile */
    overflow-x: auto;
}

/* Bot editor modal: keep the footer actions pinned, while the body scrolls. */
#botModal .modal-content {
    display: flex;
    flex-direction: column;
    overflow: hidden; /* body becomes the scroll container */
}
#botModal .modal-body {
    flex: 1 1 auto;
    min-height: 0; /* required for flex children to scroll */
    overflow-y: auto;
}
#botModal .modal-footer {
    flex: 0 0 auto;
    background: var(--card-background);
    box-shadow: 0 -10px 25px rgba(0,0,0,0.25);
}

.modal-large {
    max-width: 1000px;
}

.modal-graph {
    max-width: 1200px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.graph-header {
    padding: 1rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    align-items: flex-start;
    gap: 1rem;
}

.graph-title-group h2 {
    margin-bottom: 0.25rem;
}

.graph-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.graph-copy-report-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.graph-subtitle {
    margin: 0;
    height: 1.4rem;
    line-height: 1.4rem;
    font-size: 0.95rem;
    color: var(--muted-color);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.graph-root {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    height: 100%;
    overflow: hidden;
}

.graph-viewport {
    flex: 1 1 auto;
    border-radius: 0.75rem;
    position: relative;
    min-height: 520px;
    border: 1px solid rgba(255,255,255,0.06);
    background: radial-gradient(900px 500px at 20% 15%, rgba(139,92,246,0.22), transparent 65%),
                radial-gradient(800px 520px at 80% 85%, rgba(14,165,233,0.18), transparent 60%),
                rgba(10,12,20,0.92);
    overflow: hidden;
}

.graph-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(232,238,249,0.85);
    background: linear-gradient(135deg, rgba(12,16,24,0.85), rgba(12,16,24,0.35));
    backdrop-filter: blur(4px);
    z-index: 2;
    pointer-events: none;
}

.graph-sidebar {
    flex: 0 0 260px;
    background: rgba(17,21,31,0.85);
    border-radius: 0.75rem;
    border: 1px solid rgba(255,255,255,0.08);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

.graph-sidebar h3 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(232,238,249,0.8);
}

.graph-legend-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.graph-legend-btn {
    flex: 1 1 48%;
    border: 1px solid rgba(139,92,246,0.35);
    background: linear-gradient(135deg, rgba(17,24,39,0.92), rgba(27,38,58,0.78));
    color: rgba(232,238,249,0.88);
    font-size: 0.78rem;
    padding: 0.35rem 0.55rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    box-shadow: inset 0 0 0 1px rgba(148,163,184,0.12), 0 8px 16px rgba(11,14,23,0.45);
}

.graph-legend-btn:hover {
    background: linear-gradient(135deg, rgba(62,45,119,0.92), rgba(139,92,246,0.35));
    border-color: rgba(148,163,184,0.45);
    color: #f8fafc;
}

.graph-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow-y: auto;
    max-height: 240px;
    scrollbar-width: thin;
}

.graph-legend-item {
    display: block;
}

.graph-legend-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.92rem;
    color: rgba(232,238,249,0.88);
}

.graph-legend-label input[type="checkbox"] {
    accent-color: var(--primary-color);
    width: 16px;
    height: 16px;
}

.graph-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(139,92,246,0.35);
}

.graph-legend-text {
    flex: 1;
}

.graph-hints {
    font-size: 0.85rem;
    color: var(--muted-color);
    line-height: 1.4;
}

.graph-error {
    font-size: 0.9rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(239,68,68,0.4);
    background: rgba(239,68,68,0.12);
    color: #fecaca;
}

.graph-error.hidden {
    display: none;
}

@media (max-width: 1280px) {
    .modal-graph {
        height: 75vh;
    }
}

@media (max-width: 1024px) {
    .graph-root {
        flex-direction: column;
    }
    .graph-sidebar {
        flex: 0 0 auto;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }
    .graph-legend {
        flex: 1 1 60%;
        max-height: 160px;
    }
    .graph-hints, .graph-error {
        flex: 1 1 35%;
    }
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Bot editor header section selector (replaces the large sticky button row). */
#botModal .modal-header {
    gap: 12px;
}
.bot-modal-header-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}
.bot-section-select-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.bot-section-select {
    /* Hint to the browser that this control is intended for a dark UI (helps native dropdown theming). */
    color-scheme: dark;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.85);
    border-radius: 9999px;
    padding: 0.42rem 2.25rem 0.42rem 0.9rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 170px;
    line-height: 1.1;
}
.bot-section-select option,
.bot-section-select optgroup {
    background: #0f1520;
    color: rgba(255,255,255,0.92);
}
.bot-section-select:focus-visible {
    outline: 2px solid rgba(107,134,255,0.8);
    outline-offset: 2px;
}
.bot-section-select-icon {
    position: absolute;
    right: 12px;
    pointer-events: none;
    color: rgba(255,255,255,0.65);
    font-size: 0.85rem;
}
@media (max-width: 640px) {
    .bot-section-select {
        min-width: 140px;
    }
}

.modal-header h2 {
    margin: 0;
}

.close {
    font-size: 1.5rem;
    font-weight: 700;
    color: #6b7280;
    cursor: pointer;
}

.close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(255,255,255,0.08);
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Form Elements */
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: inherit;
}

/* Tabs */
.tab-container {
    display: flex;
    flex-direction: column;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    color: #6b7280;
    font-weight: 500;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.tab-pane {
    display: none;
    padding: 1rem 0;
}

.tab-pane.active {
    display: block;
}

.bot-form-nav {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 -1rem 1rem;
    padding: 0.5rem 1rem;
    background: var(--card-background);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.bot-nav-btn {
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.75);
    border-radius: 9999px;
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.bot-nav-btn:hover,
.bot-nav-btn:focus-visible {
    color: var(--text-color);
    border-color: rgba(255,255,255,0.18);
}

.bot-nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--ring);
}

.bot-nav-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.bot-section {
    margin-bottom: 2rem;
}

.memory-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.memory-actions .form-select {
    flex: 1 1 220px;
    max-width: 360px;
}

.memory-action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1 1 260px;
}

.memory-action-buttons .btn {
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 150px;
}

/* Conversations tab: keep action buttons same size (avoid the last button taking a full row width). */
.conversation-action-buttons .btn {
    flex: 0 0 170px;
    min-width: 170px;
    width: 170px;
    white-space: nowrap;
    text-align: center;
}

@media (max-width: 640px) {
    .conversation-action-buttons .btn {
        flex: 1 1 170px;
        width: auto;
    }
}

/* In-Agent Memory tab: keep editor buttons compact (override default memory-action-buttons sizing). */
.agent-memory-action-buttons {
    flex: 0 0 auto;
    justify-content: flex-start;
}

.agent-memory-action-buttons .btn {
    flex: 0 0 auto;
    min-width: 0;
    width: auto;
}

.agent-memory-action-buttons .btn-primary {
    width: auto;
}

.memory-content {
    background: rgba(255,255,255,0.03);
    padding: 1rem;
    border-radius: 0.375rem;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
}

/* Conversation viewer (Agent Memories -> Conversations) */
.chat-message {
    position: relative;
    margin: 0.75rem 0;
    padding: 0.85rem 0.95rem;
    border-radius: 0.6rem;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(15, 21, 32, 0.45);
}

.chat-message.user {
    border-left: 4px solid rgba(59, 130, 246, 0.65);
}

.chat-message.assistant {
    border-left: 4px solid rgba(16, 185, 129, 0.65);
}

.chat-message .message-role {
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    margin-right: 0.35rem;
}

.chat-message .message-text {
    margin-top: 0.35rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: rgba(255,255,255,0.85);
}

.chat-message .message-timestamp {
    margin-top: 0.45rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
}

.chat-message .message-actions {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    display: flex;
    gap: 0.35rem;
}

/* icon-btn defaults are tuned for light tables; override inside dark chat bubbles */
.chat-message .icon-btn {
    color: rgba(255,255,255,0.7);
}

.chat-message .icon-btn:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.95);
}

.chat-message .icon-btn.is-loading {
    opacity: 0.6;
    cursor: progress;
}

.chat-message .message-translation {
    margin-top: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px dashed rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.04);
}

.chat-message .message-translation-meta {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 0.35rem;
}

.chat-message .message-translation-text {
    white-space: pre-wrap;
    word-break: break-word;
    color: rgba(255,255,255,0.9);
}

.memory-meta {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.65);
}

.memory-priority, .memory-category {
    display: inline-block;
    margin-right: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    background: rgba(59,130,246,0.15);
    color: rgba(147,197,253,0.95);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.memory-priority {
    background: rgba(249,115,22,0.2);
    color: rgba(251,191,36,0.95);
}

.memory-subsection {
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(15,21,32,0.45);
}

.memory-section-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
}

.form-select {
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    min-width: 200px;
}

/* Compact select controls inside the memories modal */
.memory-actions select.form-select,
.trait-form .form-actions select.form-select {
    padding: 0.35rem 0.55rem;
    font-size: 0.95rem;
    line-height: 1.2;
    height: 2.1rem;
    min-height: 2.1rem;
}

@media (max-width: 640px) {
    .memory-actions select.form-select,
    .trait-form .form-actions select.form-select {
        padding: 0.3rem 0.5rem;
        font-size: 0.85rem;
        line-height: 1.1;
        height: 1.85rem;
        min-height: 1.85rem;
    }
}

/* Generic form control styling (inputs/textareas/selects using .form-control) */
.form-control {
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.12);
    background: #0f1520;
    color: var(--text-color);
    border-radius: 0.375rem;
    font-size: 1rem;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--ring);
}
::placeholder { color: var(--muted-color); opacity: 1; }

/* Tables (dark theme) */
.table { width: 100%; border-collapse: collapse; color: var(--text-color); }
.table th, .table td { border-bottom: 1px solid rgba(255,255,255,0.08); padding: 0.5rem; text-align: left; }
.table-striped tbody tr:nth-child(odd) { background: rgba(255,255,255,0.03); }
.table tbody tr:hover { background: #1d1a29; }

.table-scroll {
    overflow-x: auto;
    margin-bottom: 0.75rem;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table-scroll table {
    min-width: 100%;
    white-space: nowrap;
}

.wrap-text {
    display: inline-block;
    max-width: 28ch;
    white-space: normal;
    word-break: break-word;
}
@media (max-width: 768px) {
    .wrap-text { max-width: 20ch; }
}

/* LLM table: allow long model/class names to wrap instead of forcing horizontal scroll */
#llmTable th,
#llmTable td {
    white-space: normal;
    word-break: break-word;
}

/* LLM history modal: opt out of the generic table nowrap rule so payload previews can fit the modal width. */
#llmHistoryModal .table-scroll {
    overflow-x: hidden;
}

#llmHistoryTable {
    width: 100%;
    table-layout: fixed;
}

#llmHistoryTable th,
#llmHistoryTable td {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
}

#middlewaresTable th,
#middlewaresTable td,
#mcpConnectorsTable th,
#mcpConnectorsTable td {
    white-space: normal;
    word-break: break-word;
}

/* LLM actions: keep edit/delete buttons aligned */
.llm-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.llm-actions .btn {
    min-width: 72px;
    width: auto;
    flex: 0 0 auto;
    text-align: center;
    white-space: nowrap;
}

/* Keep the per-row LLM action set on one line without affecting modal toolbars. */
#llmTable .llm-actions {
    flex-wrap: nowrap;
    white-space: nowrap;
}

#llmTable .llm-actions .btn:not(.llm-history-btn) {
    min-width: 0;
}

.llm-actions .llm-history-btn {
    min-width: 30px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(51, 65, 85, 0.95);
    border-radius: 8px;
    background: #0f172a;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.llm-actions .llm-history-btn:hover {
    background: #020617;
    color: #f8fafc;
    border-color: rgba(71, 85, 105, 0.95);
}

.llm-actions .llm-history-btn i {
    font-size: 0.8rem;
}

.log-preview {
    display: inline-block;
    max-width: 28ch;
    padding: 0.2rem 0.35rem;
    margin: 0.125rem 0;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0.3rem;
    background: rgba(15,21,32,0.85);
    color: inherit;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
}
.log-preview:hover,
.log-preview:focus-visible {
    border-color: var(--primary-color);
    background: rgba(37,99,235,0.18);
    outline: none;
}
.log-preview:focus-visible {
    box-shadow: 0 0 0 2px var(--ring);
}
.log-preview--truncated {
    font-weight: 500;
}

.sequential-log-preview {
    color: #111827;
    background: #ffffff;
    border-color: rgba(17, 24, 39, 0.35);
    box-shadow: 0 1px 3px rgba(0,0,0,0.28);
}

.sequential-log-preview:hover,
.sequential-log-preview:focus-visible {
    color: #000000;
    background: #f8fafc;
    border-color: var(--primary-color);
}

.decision-provenance-shell {
    background: var(--card-background);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.22);
}

.decision-provenance-title {
    font-weight: 800;
    color: var(--text-color);
    margin-bottom: 6px;
}

.decision-provenance-subtitle {
    font-size: 12px;
    color: var(--muted-color);
    margin-bottom: 10px;
}

.decision-provenance-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.decision-provenance-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    color: var(--text-color);
    font-size: 12px;
}

.decision-provenance-badge {
    background: var(--decision-provenance-badge-color, #6b7280);
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.decision-provenance-event {
    position: relative;
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.decision-provenance-time,
.decision-provenance-chat,
.decision-provenance-empty {
    color: var(--muted-color);
}

.decision-provenance-time {
    font-size: 12px;
    white-space: nowrap;
}

.decision-provenance-card {
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 12px;
    background: rgba(255,255,255,0.035);
    padding: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.20);
}

.decision-provenance-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.decision-provenance-chat {
    font-size: 11px;
    white-space: nowrap;
}

.decision-provenance-summary {
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 6px;
}

.decision-provenance-details {
    color: var(--text-color);
    line-height: 1.45;
}

@media (max-width: 700px) {
    .decision-provenance-event {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

#toolLogViewerModal {
    z-index: 1500;
}
#toolLogViewerModal .modal-content {
    max-width: 900px;
}

#planStepsModal {
    z-index: 1500;
}
#planStepsModal .modal-content {
    max-width: 980px;
}

.plan-steps-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plan-steps-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.plan-steps-meta-item {
    background: rgba(15, 21, 32, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 56px;
}

.plan-steps-meta-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-color);
}

.plan-steps-meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    word-break: break-word;
}

.plan-steps-summary {
    display: none;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 21, 32, 0.6);
    color: var(--text-color);
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.plan-steps-loading {
    font-size: 0.9rem;
    color: var(--muted-color);
}

.plan-steps-error {
    font-size: 0.9rem;
    color: #fca5a5;
    background: rgba(190, 18, 60, 0.12);
    border: 1px solid rgba(252, 165, 165, 0.3);
    border-radius: 6px;
    padding: 10px 12px;
}

.plan-steps-table td,
.plan-steps-table th {
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
}

.plan-steps-table th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-color);
}

.plan-steps-table td:nth-child(1) {
    width: 48px;
    font-weight: 600;
}

.plan-steps-table td:nth-child(3) {
    width: 140px;
}

.plan-steps-table td:nth-child(6) {
    width: 140px;
}

.plan-step-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.25);
    color: #e2e8f0;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.plan-step-status--completed {
    background: rgba(22, 163, 74, 0.2);
    border-color: rgba(22, 163, 74, 0.4);
    color: #bbf7d0;
}

.plan-step-status--pending {
    background: rgba(234, 179, 8, 0.18);
    border-color: rgba(234, 179, 8, 0.35);
    color: #fef3c7;
}

.plan-step-status--in-progress,
.plan-step-status--active {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.35);
    color: #bfdbfe;
}

.plan-step-status--blocked,
.plan-step-status--cancelled {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.38);
    color: #fecaca;
}

.plan-step-status--skipped {
    background: rgba(45, 212, 191, 0.18);
    border-color: rgba(45, 212, 191, 0.35);
    color: #99f6e4;
}

.plan-step-status--unknown {
    background: rgba(148, 163, 184, 0.25);
    border-color: rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
}

.tool-meta {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--muted-color);
    white-space: normal;
}

.tool-param {
    display: inline-block;
    max-width: 320px;
    padding: 0.1rem 0.4rem;
    border-radius: 0.375rem;
    background: rgba(139, 92, 246, 0.15);
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.tool-actions {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tools-tab-container .tab-buttons {
    gap: 4px;
}

.tools-tab-container .tab-buttons .tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mcp-actions {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (min-width: 768px) {
    .mcp-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .mcp-actions .tool-search {
        max-width: 320px;
    }
}

#mcpConnectorsTable td {
    vertical-align: middle;
}

#mcpConnectorList .mcp-row {
    display: grid;
    grid-template-columns: minmax(220px, 240px) 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

#mcpConnectorList .mcp-row-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

#mcpConnectorList .mcp-row-actions .btn {
    min-width: 82px;
}

.rights-summary {
    margin-right: 8px;
    display: inline-block;
}

#mcpConnectorList .mcp-rights {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.mcp-summary {
    font-size: 0.9rem;
    color: var(--muted-color);
    background: rgba(255, 255, 255, 0.04);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    min-height: 42px;
    display: flex;
    align-items: center;
}

.mcp-summary.muted {
    color: rgba(255, 255, 255, 0.45);
}

#mcpConnectorList .btn-danger {
    justify-self: end;
}

#botKnowledgeConnectorList .kc-row {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

#botKnowledgeConnectorList .kc-row-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

#botKnowledgeConnectorList .kc-row-actions .form-control {
    min-width: 110px;
}

#botKnowledgeConnectorList .kc-overrides {
    margin: 8px 0 14px;
}

@media (max-width: 640px) {
    #mcpConnectorList .mcp-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    #mcpConnectorList .mcp-row-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    #botKnowledgeConnectorList .kc-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    #botKnowledgeConnectorList .kc-row-actions {
        justify-content: flex-start;
    }
}

#botGuardList {
    display: flex;
    flex-direction: column;
}

.guard-row {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.guard-row .guard-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    align-items: center;
}

.guard-row .guard-enabled {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.95rem;
}

.guard-row .guard-config {
    min-height: 64px;
    resize: vertical;
}

.guard-row .btn-danger {
    justify-self: flex-start;
}

.guard-test {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 0.6rem;
    padding: 1rem;
}

.guard-test-result {
    margin-top: 0.75rem;
    background: rgba(17, 24, 39, 0.65);
    color: var(--text-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
    max-height: 260px;
    overflow: auto;
    font-size: 0.9rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.category-card {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.category-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.category-actions {
    display: flex;
    gap: 8px;
}

.category-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.category-table {
    max-height: 240px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
}

.category-form {
    background: rgba(255,255,255,0.02);
    border-radius: 6px;
    padding: 12px;
}

.category-placeholder {
    padding: 24px;
    text-align: center;
    color: var(--muted-color);
}

@media (max-width: 768px) {
    .category-body {
        flex-direction: column;
    }
}

.tool-search {
    width: 100%;
}

.tool-search .form-control {
    width: 100%;
    padding: 0.6rem 0.75rem;
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .modal-content {
        margin: 1rem;
        width: auto;
    }
    
    .tab-buttons {
        flex-wrap: wrap;
    }
}

/* Add to ./adm/css/styles.css */

.add-trait-form {
    background: var(--card-background);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06) inset;
}

.trait-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.form-actions .form-select {
    flex: 1;
}

.form-actions .btn {
    white-space: nowrap;
}

.trait-form .form-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.75rem;
}

.trait-form .form-actions .form-select {
    flex: 1 1 220px;
    max-width: 360px;
}

.trait-form .form-actions .btn {
    font-size: 0.9rem;
    padding: 0.45rem 0.9rem;
}

.trait-form .form-actions .btn-primary {
    width: auto;
}

.personality-compact-panel {
    background: var(--card-background);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.04) inset;
    margin: 0 0 1rem;
    padding: 1rem;
}

.personality-compact-header,
.personality-compact-snapshot,
.personality-compact-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.personality-compact-header h3 {
    margin: 0 0 0.35rem;
}

.personality-compact-header p,
.personality-compact-snapshot p {
    margin: 0.15rem 0;
    color: var(--text-secondary);
}

.personality-compact-group {
    border-top: 1px solid rgba(255,255,255,.08);
    margin-top: 1rem;
    padding-top: 1rem;
}

.personality-compact-group h4 {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 0.75rem;
}

.personality-compact-group ul {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}

.personality-compact-group li {
    margin-bottom: 0.45rem;
    white-space: pre-wrap;
}

.personality-compact-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.personality-compact-status {
    color: var(--text-secondary);
}

.personality-compact-status.success {
    color: var(--success-color);
}

.personality-compact-status.error,
.personality-compact-warnings {
    color: var(--danger-color);
}

.personality-compact-warnings {
    margin-top: 0.75rem;
}

.personality-compact-actions {
    justify-content: flex-end;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .personality-compact-header,
    .personality-compact-snapshot,
    .personality-compact-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

.token-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.token-input-group input {
    flex: 1;
}

.token-input-group .btn {
    padding: 0.5rem;
    min-width: 40px;
}

.instruction-item {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    position: relative;
}

.instruction-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: #2563eb;
}

.launch-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.launch-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
}

/* Improve spacing for Event API Docs modal */
#eventApiDocsModal .modal-body {
    padding: 1.5rem 2rem; /* add extra space away from borders */
}
#eventApiDocsModal .modal-body p {
    margin-bottom: 0.75rem;
}
#eventApiDocsModal .modal-body ul {
    margin-left: 1.25rem;
    margin-bottom: 0.75rem;
}
#eventApiDocsModal pre {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
}
.modal-body {
    padding: 1rem;
    overflow-x: auto;
    overflow-y: auto;
}

.dist-list-group {
    margin-top: 12px;
}

.dist-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.dist-search-row {
    margin: 6px 0 8px;
}

.dist-search {
    max-width: 520px;
}

.dist-list-title {
    font-weight: 600;
}

.dist-list-toggle {
    font-weight: 400;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.dist-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dist-list li {
    margin-bottom: 6px;
}

.dist-list li:last-child {
    margin-bottom: 0;
}

.dist-list label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.dist-list label input[type="checkbox"] {
    margin: 0;
}

.dist-item-name {
    font-weight: 600;
}

.dist-item-desc {
    color: #666;
}

.dist-count {
    color: #888;
    font-size: 0.9em;
}
.dist-list-toggle input[type="checkbox"] {
    margin: 0;
}
.bot-card-header h2 {
    margin: 0;
    font-size: 1.25rem;
    min-width: 0;
    word-break: break-word;
}


.logs-tab-container {
    margin-top: 8px;
}

.logs-tab-container .tab-buttons {
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}

.logs-tab-container .tab-btn {
    border-radius: 0;
    background: none;
    padding: 0.5rem 1rem;
    color: #6b7280;
    border-bottom: 2px solid transparent;
}

.logs-tab-container .tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Logs modal: infinite scroll status + load more */
.logs-actions {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.logs-status {
    margin-left: auto;
    font-size: 0.85rem;
    color: rgba(154, 163, 178, 0.9);
}
.logs-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}
.logs-footer-status {
    font-size: 0.85rem;
    color: rgba(154, 163, 178, 0.9);
    white-space: nowrap;
}
.logs-footer .btn.btn-sm {
    height: 32px;
    padding: 0 0.75rem;
    line-height: 1;
}


.log-entry {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    line-height: 1.4;
}
.log-entry .log-message {
    font-size: 0.9rem;
    color: rgba(232, 238, 249, 0.85);
}
.log-entry .log-time {
    font-size: 0.8rem;
    color: rgba(154, 163, 178, 0.8);
}

.code-block {
    position: relative;
    margin: 12px 0;
    border-radius: 6px;
    overflow: hidden;
}
.code-block pre {
    margin: 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.875rem;
    line-height: 1.45;
    padding: 16px 18px;
}
.code-block--dark {
    background: #0b0f1a;
    border: 1px solid rgba(255,255,255,0.12);
    color: #f5f7ff;
}
.code-block--dark pre {
    color: inherit;
}
.code-block__copy {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.08);
    color: #f5f7ff;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.code-block__copy:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.25);
}
.code-block__copy.is-copied {
    background: rgba(16,185,129,0.2);
    border-color: rgba(16,185,129,0.6);
    color: #34d399;
}
.tool-row td {
    border-bottom: none;
    vertical-align: middle;
}
.tool-row + .tool-row td {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Prompt helper UI */
.prompt-helper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
}

.prompt-helper .form-control {
    width: 100%;
    min-width: 0;
}

.prompt-helper textarea.form-control {
    min-height: 120px;
    resize: vertical;
    line-height: 1.4;
}

.prompt-helper__actions {
    position: relative;
    align-self: flex-end;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.preprompt-actions-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.preprompt-actions-bar .btn {
    white-space: nowrap;
}

.preprompt-actions-bar .btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.preprompt-actions-bar .rights-summary {
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
    padding: 0.2rem 0.5rem;
    margin-right: 0;
}

.prompt-helper__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--card-background);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text-color);
    padding: 0.45rem 0.8rem;
    border-radius: 0.5rem;
    white-space: nowrap;
}

.prompt-helper__toggle:hover {
    background: rgba(139, 92, 246, 0.18);
}

.prompt-helper__toggle[disabled] {
    opacity: 0.65;
    cursor: not-allowed;
}

.prompt-helper__caret {
    font-size: 0.85rem;
}

.prompt-helper__menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--card-background);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.55rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    min-width: 220px;
    padding: 0.35rem;
    display: none;
    z-index: 20;
}

.prompt-helper__menu.open {
    display: block;
}

.prompt-helper__menu button {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-color);
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.prompt-helper__menu button:hover {
    background: rgba(139, 92, 246, 0.2);
}

.prompt-helper__status {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted-color);
    min-height: 1.1rem;
}

.prompt-helper__status.is-success {
    color: #4ade80;
}

.prompt-helper__status.is-error {
    color: var(--error-color);
}

.prompt-helper__field-updated {
    animation: prompt-helper-pulse 1s ease;
}

@keyframes prompt-helper-pulse {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.35); }
    100% { box-shadow: 0 0 0 16px rgba(139, 92, 246, 0); }
}

.prompt-preview-button {
    display: inline-flex;
    align-items: center;
    max-width: 320px;
    width: 100%;
    background: rgba(3, 6, 15, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    padding: 0.45rem 0.65rem;
    border-radius: 0.45rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.prompt-preview-button:hover {
    border-color: rgba(139, 92, 246, 0.75);
    background: rgba(17, 24, 39, 0.92);
    transform: translateY(-1px);
}

/* Schedules modal: keep prompt preview compact to avoid horizontal scrolling on desktop. */
#schedulesTable .prompt-preview-button {
    max-width: 220px;
    width: auto;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
}

/* Schedules modal: avoid flex on <td> (can cause border/row divider offsets). */
#schedulesTable td.action-cell {
    display: table-cell;
    white-space: nowrap;
}
#schedulesTable td.action-cell .table-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: center;
    white-space: nowrap;
}

.preprompt-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.preprompt-row:last-child {
    margin-bottom: 0;
}

.preprompt-row .preprompt-delete {
    align-self: center;
}

.tier-chip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: #1f2432;
    border-radius: 16px;
    padding: 8px 16px;
    margin: 12px 0 20px;
    font-size: 0.9rem;
    color: #f8fafc;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}

.tier-chip .tier-badge {
    margin-right: 6px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
}

.tier-chip-metric {
    color: #d1d9e6;
    font-size: 0.82rem;
}

.tier-chip-link {
    margin-left: auto;
}

.tier-chip-link a {
    color: inherit;
    text-decoration: none;
}

.tier-chip-link a:hover,
.tier-chip-link a:focus {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .tier-chip {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        font-size: 0.8rem;
        -webkit-overflow-scrolling: touch;
    }
    .tier-chip > span {
        white-space: nowrap;
    }
}
.tier-badge {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    text-transform: capitalize;
}

.tier-badge.tier-free {
    background: #e7f0ff;
    color: #1b4d8c;
}

.tier-badge.tier-plus {
    background: #e8f6ff;
    color: #0b7285;
}

.tier-badge.tier-pro {
    background: #f6edf9;
    color: #5a189a;
}

.tier-badge.tier-enterprise {
    background: #fff3cd;
    color: #856404;
}

.tier-badge.tier-internal {
    background: #e7f7ef;
    color: #0f5132;
}

.tier-config-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.tier-config-usage {
    font-size: 0.85rem;
    color: #d1d9e6;
}

.clients-table-actions,
.team-table-actions,
.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
    /* Keep action buttons on a single row; the modal can scroll horizontally if needed. */
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* Accounts (Clients) table: truncate long company/email and allow click-to-copy without horizontal scrolling. */
.truncate-copy {
    display: inline-block;
    max-width: 18ch; /* matches ~"derzeter@gmail.com" */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    cursor: copy;
    user-select: none;
}
.truncate-copy:hover {
    text-decoration: underline;
}
.truncate-copy:focus {
    outline: none;
    border-radius: 4px;
    box-shadow: 0 0 0 2px var(--ring);
}
.truncate-copy.copied {
    color: var(--accent1);
}

/* Normalize Accounts team action button heights. */
.team-actions .btn {
    width: auto;
    white-space: nowrap;
    height: 40px;
    padding: 0 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-sizing: border-box;
}

#manageRolesButton,
#showTeamMemberForm,
#showPortalUserForm {
    height: 40px;
    padding: 0 1rem;
    line-height: 1;
    width: auto;
    box-sizing: border-box;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
    background: rgba(148, 163, 184, 0.12);
    color: #1f2937;
}

.icon-btn:focus {
    outline: 2px solid rgba(59, 130, 246, 0.45);
    outline-offset: 1px;
}

.icon-btn i {
    font-size: 0.9rem;
}

.icon-btn.icon-danger {
    color: #dc2626;
}

.icon-btn.icon-danger:hover {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.credit-adjust-group .credit-adjust-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.credit-adjust-group .credit-adjust-controls .form-control {
    max-width: 120px;
}

.sandboxed-tools-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sandboxed-tools-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.sandboxed-tools-header .subtext {
    color: var(--muted-color);
    font-size: 0.9rem;
}

.sandboxed-tools-notice {
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--muted-color);
}

.sandboxed-tools-notice.sandboxed-error {
    border-color: rgba(239,68,68,0.4);
    color: #fecaca;
}

.sandboxed-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.sandboxed-loading {
    padding: 1rem;
    color: var(--muted-color);
    font-size: 0.9rem;
}

.sandboxed-card {
    background: var(--card-background);
    border-radius: 0.9rem;
    border: 1px solid rgba(255,255,255,0.05);
    padding: 1rem;
    box-shadow: 0 15px 30px rgba(0,0,0,0.25);
}

.sandboxed-card-head {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.sandboxed-command {
    font-weight: 600;
    font-size: 1rem;
}

.sandboxed-label {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.sandboxed-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted-color);
    margin: 0.35rem 0 0.5rem;
}

.template-tag {
    background: rgba(139,92,246,0.12);
    color: var(--accent2);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
}

.status-badge {
    padding: 0.15rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Tool-generated Admin Notifications (Bot Files → Notifications) */
.notif-unread td {
    background: rgba(59, 130, 246, 0.08);
}
.notif-pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
    background: #0b1220;
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    padding: 10px 12px;
    max-height: 420px;
    overflow: auto;
}

/* LLM history modal: inline detail rows + foldable JSON tree viewer. */
.llm-history-row td {
    vertical-align: top;
}

.llm-history-expand-cell {
    width: 42px;
    text-align: center;
}

.llm-history-time-cell {
    min-width: 92px;
}

.llm-history-date {
    color: #f8fafc;
    font-size: 0.82rem;
    font-weight: 600;
}

.llm-history-time {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 0.76rem;
}

.llm-history-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(71, 85, 105, 0.55);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.92);
    color: #e2e8f0;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.llm-history-toggle:hover {
    background: rgba(30, 41, 59, 0.96);
    border-color: rgba(96, 165, 250, 0.55);
    color: #f8fafc;
}

.llm-history-toggle i {
    font-size: 0.72rem;
}

.llm-history-detail-row td {
    background: rgba(17, 21, 31, 0.88);
    border-top: 1px solid rgba(71, 85, 105, 0.45);
    white-space: normal;
}

.llm-history-detail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0 10px;
    min-width: 0;
}

.llm-history-detail.loading {
    color: #cbd5e1;
}

.llm-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.llm-history-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(71, 85, 105, 0.22);
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.78rem;
}

.llm-history-status.is-success {
    background: rgba(34, 197, 94, 0.18);
    color: #86efac;
}

.llm-history-status.is-error {
    background: rgba(248, 113, 113, 0.16);
    color: #fca5a5;
}

.llm-history-wrap-cell {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 320px;
}

.llm-history-client-cell {
    min-width: 150px;
    max-width: 180px;
}

.llm-history-client-name {
    color: #f8fafc;
    font-weight: 500;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.llm-history-client-username {
    margin-top: 3px;
    color: #94a3b8;
    font-size: 0.74rem;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.llm-history-llm-cell {
    min-width: 145px;
    max-width: 170px;
}

.llm-history-llm-class {
    color: #f8fafc;
    font-weight: 600;
    line-height: 1.2;
}

.llm-history-llm-model {
    margin-top: 3px;
    color: #94a3b8;
    font-size: 0.76rem;
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.llm-history-preview-cell {
    font-size: 0.78rem;
    color: #cbd5e1;
    line-height: 1.35;
    max-width: 260px;
}

.llm-history-payload {
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

.llm-history-payload summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--text-color);
    list-style: none;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.llm-history-payload summary::-webkit-details-marker {
    display: none;
}

.llm-history-payload[open] summary {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(71, 85, 105, 0.4);
}

.llm-history-payload-actions {
    display: flex;
    justify-content: flex-end;
    padding: 10px 14px 0;
}

.llm-history-json-viewer {
    padding: 12px 14px 14px;
    overflow-x: hidden;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
    max-width: 100%;
}

.json-tree-node,
.json-tree-leaf {
    margin: 3px 0;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
    max-width: 100%;
}

.json-tree-node summary {
    cursor: pointer;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.json-tree-children {
    margin-left: 16px;
    padding-left: 10px;
    border-left: 1px solid rgba(71, 85, 105, 0.45);
    min-width: 0;
    max-width: 100%;
}

.json-tree-key {
    color: #93c5fd;
    font-weight: 600;
}

.json-tree-collection {
    color: #fbbf24;
}

.json-tree-string {
    color: #bfdbfe;
}

.json-tree-number {
    color: #fca5a5;
}

.json-tree-bool {
    color: #86efac;
}

.json-tree-null {
    color: #cbd5e1;
    opacity: 0.8;
}

.json-tree-raw,
.json-tree-empty {
    margin: 0;
    color: #cbd5e1;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
}

/* Bot card indicator: unread admin notifications */
.bot-memory-btn {
    position: relative;
}
.bot-notif-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #ef4444;
    border: 2px solid rgba(15, 23, 42, 0.95);
    display: none;
}

.adm-user-notif-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.adm-notification-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(11, 13, 18, 0.95);
}

.adm-notification-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.adm-notification-toolbar-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.adm-notification-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.adm-notification-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.adm-notification-filter-group .btn.is-active {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.55);
    color: #dbeafe;
}

.adm-notification-scroll {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 4px;
}

.adm-notification-list {
    display: grid;
    gap: 12px;
}

.adm-notification-card {
    background: rgba(31, 36, 50, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    padding: 14px 16px;
}

.adm-notification-card.is-unread {
    border-color: rgba(96, 165, 250, 0.65);
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.28);
}

.adm-notification-card.is-archived {
    opacity: 0.82;
}

.adm-notification-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.adm-notification-card-title {
    font-size: 1rem;
    font-weight: 600;
}

.adm-notification-card-meta {
    margin-top: 4px;
    color: var(--muted-color);
    font-size: 0.84rem;
}

.adm-notification-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    justify-content: flex-end;
}

.adm-notification-card-body {
    margin-top: 12px;
    color: var(--text-color);
    word-break: break-word;
}

.adm-notification-card-body p:last-child,
.adm-notification-card-body ul:last-child,
.adm-notification-card-body ol:last-child,
.adm-notification-card-body pre:last-child,
.adm-notification-card-body blockquote:last-child {
    margin-bottom: 0;
}

.adm-notification-empty {
    color: var(--muted-color);
    padding: 16px 6px;
}

@media (max-width: 768px) {
    .adm-notification-toolbar,
    .adm-notification-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .adm-notification-card-actions {
        justify-content: flex-start;
    }
}


.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.18rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}
.status-active { background: rgba(16,185,129,0.2); color: #6ee7b7; }
.status-muted { background: rgba(148,163,184,0.2); color: #cbd5f5; }
.status-error { background: rgba(239,68,68,0.2); color: #fecaca; }

.sandboxed-card-desc {
    color: var(--muted-color);
    min-height: 2.5em;
    font-size: 0.9rem;
}

.sandboxed-card-knowledge {
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: 0.75rem;
    padding: 0.65rem 0.75rem;
    margin-top: 0.6rem;
}

.sandboxed-knowledge-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-color);
    margin-bottom: 0.35rem;
}

.sandboxed-knowledge-body {
    font-size: 0.85rem;
    color: #e2e8f0;
    white-space: pre-line;
}

.sandboxed-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.sandboxed-template-info {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 0.75rem;
    padding: 0.9rem;
    margin: 0.5rem 0 1rem;
    font-size: 0.9rem;
    color: var(--muted-color);
}

.sandboxed-template-info strong {
    display: block;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.sandboxed-tool-form {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 1rem;
    padding: 1rem;
    background: rgba(17,21,31,0.85);
}

.form-row.three-cols,
.form-row.two-cols {
    display: grid;
    gap: 0.75rem;
}

.form-row.three-cols { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-row.two-cols { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.kv-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.kv-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.4rem;
}

.kv-row .icon-btn {
    background: rgba(255,255,255,0.05);
    border: none;
    color: var(--muted-color);
    border-radius: 0.6rem;
    padding: 0.4rem 0.5rem;
}

/* Comment: Bot tag chips (system + tenant) shown on agent cards and in the bot editor. */
.bot-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 10px;
}
.bot-tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.2;
    color: #ffffff;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
