
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 { flex: 1; }
.site-footer {
    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;
}

.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);
}
.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;
}
.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;
}
.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 {
    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: 3.5rem; /* increased space below the dashboard header */
}

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

.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;
    }
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .header-actions {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.75rem;
        padding: 0 0 0.5rem 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 Bot" */
.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%;
}

/* Bot Grid */
.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;
    overflow: hidden;
}

.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-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-comm-wrapper {
    position: relative;
}

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

.bot-comm-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"] {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bot-comm-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 {
    width: 1rem;
    text-align: center;
}

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

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

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

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

.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-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;
}
#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;
    gap: 6px;
}
.llm-actions .btn {
    min-width: 72px;
    text-align: center;
}

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

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

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

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

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


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

.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 {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
}

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

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