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

:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --border: #2a2a2a;
    --text: #e8e8e8;
    --muted: #888;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --warn: #f59e0b;
    --running: var(--success);
    --paused: var(--warn);
    --error: var(--danger);
    --provisioning: var(--muted);
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

[v-cloak] { display: none; }

a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { color: var(--accent-hover); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 6px; border: none;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: 0.85; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-icon-sq {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; color: var(--muted);
}
.btn-icon-sq:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,0.06); }
.btn-icon-sq svg { display: block; flex-shrink: 0; }
.btn-danger { background: var(--danger); color: white; }
.btn-large { padding: 12px 24px; font-size: 15px; }

/* ── App shell ── */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

body.landing #app {
    display: block;
    height: auto;
    overflow: visible;
}

/* ── Sidebar ── */
.sidebar {
    width: 200px;
    min-width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    padding: 0 20px 20px;
    color: var(--text);
    letter-spacing: -0.5px;
}

/* ── Sidebar bot list ── */
.sidebar-bots {
    padding: 0 10px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.sidebar-bots-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn-icon {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.btn-icon:hover { color: var(--text); }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

.sidebar-bot-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    overflow-y: auto;
}
.sidebar-bot-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}
.sidebar-bot-item:hover,
.sidebar-bot-item.active {
    background: var(--border);
    color: var(--text);
}
.sidebar-bot-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.status-dot.xs { width: 6px; height: 6px; }
.sidebar-bot-empty {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--muted);
}
.unread-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-nav {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
}

.sidebar-nav a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--border);
    color: var(--text);
}

.sidebar-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-email {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Main content ── */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    min-width: 0;
}

.main:has(.bot-detail) {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.empty-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}
.bot-actions { display: flex; gap: 8px; }

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--muted);
}
.status-dot.running { background: var(--running); }
.status-dot.paused { background: var(--paused); }
.status-dot.error { background: var(--error); }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty-state p { margin-bottom: 16px; }
.empty { color: var(--muted); padding: 20px 0; }

/* ── Bot detail layout ── */
.bot-detail {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.bot-detail .page-header {
    flex-shrink: 0;
}

.detail-columns {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.detail-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.detail-right {
    width: 340px;
    min-width: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    flex-shrink: 0;
}

.panel-header {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    font-weight: 600;
}

.budget-status {
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text);
}

.detail-settings {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 16px;
    flex-shrink: 0;
}

.settings-form-inline .settings-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}
.settings-form-inline .settings-row .form-group {
    flex: 1;
    margin-bottom: 0;
}
.settings-form-inline > .form-group {
    margin-bottom: 12px;
}

/* ── Stat cards ── */
.stat-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stat-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 16px; font-weight: 600; text-transform: capitalize; }
.stat-value.running { color: var(--running); }
.stat-value.paused { color: var(--paused); }
.stat-value.error { color: var(--error); }

/* ── Costs ── */
.cost-summary {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    color: var(--muted);
}
.cost-summary strong { color: var(--text); }

.budget-form {
    margin-bottom: 0;
}
.budget-form label { display: block; color: var(--muted); margin-bottom: 6px; font-size: 12px; }
.input-row { display: flex; gap: 8px; }
.input-row input { width: 140px; }
.limits-grid { display: flex; gap: 16px; flex-wrap: wrap; max-width: 500px; }
.limits-grid .form-group { margin-bottom: 0; }

.cost-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.cost-table th, .cost-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.cost-table th { color: var(--muted); font-weight: 500; }

/* ── Messages ── */
.panel .message-list { max-height: 200px; overflow-y: auto; }
.message-list { display: flex; flex-direction: column; gap: 6px; }
.message-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 8px;
    border-radius: 6px;
}
.message-row.in { background: rgba(99,102,241,0.08); }
.msg-dir { color: var(--muted); font-size: 12px; min-width: 16px; margin-top: 1px; }
.msg-content { flex: 1; font-size: 13px; overflow-x: auto; }
.msg-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ── Markdown inside messages (activity panel + chat bubbles) ── */
.msg-content p, .chat-bubble-content p { margin: 0 0 8px; }
.msg-content p:last-child, .chat-bubble-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3,
.chat-bubble-content h1, .chat-bubble-content h2, .chat-bubble-content h3 { margin: 12px 0 6px; font-size: 14px; font-weight: 600; }
.msg-content h1, .chat-bubble-content h1 { font-size: 16px; }
.msg-content ul, .msg-content ol, .chat-bubble-content ul, .chat-bubble-content ol { margin: 4px 0 8px 20px; padding: 0; }
.msg-content li, .chat-bubble-content li { margin-bottom: 2px; }
.msg-content table, .chat-bubble-content table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12px; }
.msg-content th, .msg-content td, .chat-bubble-content th, .chat-bubble-content td { border: none; border-bottom: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.msg-content th, .chat-bubble-content th { font-weight: 700; border-bottom: 2px solid var(--text); padding-bottom: 8px; }
.msg-content tr:last-child td, .chat-bubble-content tr:last-child td { border-bottom: none; }
.msg-content pre, .chat-bubble-content pre { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 8px; overflow-x: auto; margin: 8px 0; }
.msg-content code, .chat-bubble-content code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.msg-content pre code, .chat-bubble-content pre code { background: none; padding: 0; }
.msg-content blockquote, .chat-bubble-content blockquote { border-left: 3px solid var(--border); margin: 8px 0; padding: 4px 12px; color: var(--muted); }
.msg-content hr, .chat-bubble-content hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.chat-bubble-content { overflow-x: auto; }

/* ── Forms ── */
.settings-form { max-width: 480px; }
.settings-form-inline { max-width: none; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}
.form-group small { color: var(--muted); font-size: 11px; display: block; margin-top: 4px; }
input, select, textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
}
textarea { resize: vertical; }

.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; }
.success-msg { color: var(--success); font-size: 13px; margin-left: 12px; }

/* ── Badges ── */
.badge { padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-warn { background: rgba(245,158,11,0.15); color: var(--warn); }

/* ── Integrations ── */
.centered-page { max-width: 640px; margin: 0 auto; }
.integration-list { display: flex; flex-direction: column; gap: 12px; }
.integration-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}
.integration-card > div:first-child { flex: 1; }
.integration-card strong { display: block; margin-bottom: 4px; }
.integration-card > div:first-child div { color: var(--muted); font-size: 12px; }
.badge-connected { background: rgba(34,197,94,0.12); color: var(--success); font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; margin-left: 8px; }
.integration-card-google { flex-direction: column; align-items: stretch; }
.integration-card-header {
    display: flex; align-items: center; gap: 12px;
}
.integration-card-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; }
.integration-card-header > div { flex: 1; }
.integration-card-header > div:last-child { flex: none; }
.integration-products {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.integration-product {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    border-radius: 6px; background: var(--bg);
}
.integration-product strong { display: inline; margin-bottom: 0; font-size: 13px; }
.integration-product .muted { display: block; font-size: 11px; }
.integration-icon { width: 32px; height: 32px; flex-shrink: 0; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 480px;
    max-width: 95vw;
}
.modal h3 { margin-bottom: 20px; font-size: 16px; }
.modal-header { display: flex; align-items: center; gap: 12px; }
.modal-header h3 { margin-bottom: 0; }
.modal-body { margin: 16px 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Chat ── */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.chat-messages {
    flex: 1 1 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 16px;
    min-height: 0;
    position: relative;
}
.chat-empty {
    color: var(--muted);
    text-align: center;
    padding: 60px 20px;
}

/* ── Chat Welcome (onboarding) ── */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 40px;
    flex: 1;
}
.chat-welcome-hero {
    text-align: center;
    margin-bottom: 24px;
}
.chat-welcome-hero h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.chat-welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 400px;
    margin-bottom: 32px;
}
.chip {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.chip:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}
.chat-welcome-setup {
    width: 100%;
    max-width: 360px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}
.setup-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 10px 14px 6px;
}
.setup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
    border-top: 1px solid var(--border);
}
.setup-row:hover {
    background: rgba(255, 255, 255, 0.03);
}
.setup-icon {
    color: var(--accent);
    font-size: 10px;
    flex-shrink: 0;
}
.setup-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
.setup-desc {
    font-size: 12px;
    flex: 1;
    text-align: right;
}
.setup-arrow {
    font-size: 12px;
    flex-shrink: 0;
}
.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}
.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 3px;
}
.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
}

/* ── Chat separator (cron/webhook) ── */
.chat-separator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0 4px;
    color: var(--muted);
    font-size: 11px;
    align-self: stretch;
}
.chat-separator::before,
.chat-separator::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}
.chat-separator-time {
    opacity: 0.7;
}
.chat-bubble-content pre {
    background: rgba(0,0,0,0.3);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 12px;
}
.chat-bubble-content code {
    background: rgba(0,0,0,0.2);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}
.chat-bubble-content pre code {
    background: none;
    padding: 0;
}

/* ── Code block copy button ── */
.code-block-wrap {
    position: relative;
}
.code-block-wrap .code-lang {
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
}
.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.code-block-wrap:hover .code-copy-btn {
    opacity: 1;
}
.code-copy-btn:hover {
    background: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.9);
}

/* ── Stop button ── */
.btn-stop {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    margin-right: 12px;
    transition: background 0.15s;
}
.btn-stop::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='2' y='2' width='12' height='12' rx='2' fill='%23e8e8e8'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}
.btn-stop:hover {
    background: var(--border);
}

/* ── Scroll to bottom ── */
.scroll-to-bottom {
    position: sticky;
    bottom: 8px;
    align-self: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    z-index: 10;
    transition: background 0.15s, border-color 0.15s;
    margin-top: -52px;
    opacity: 0.86;
}
.scroll-to-bottom::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2 L8 13 M3 8 L8 13 L13 8' stroke='%23e8e8e8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}
.scroll-to-bottom:hover {
    background: var(--border);
    border-color: var(--text);
}

.chat-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.chat-tool {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(99,102,241,0.12);
    color: var(--muted);
    position: relative;
    overflow: hidden;
}
/* Running shimmer */
.chat-tool:not(.done)::after {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
    animation: tool-shimmer 2.2s ease-in-out infinite;
}
@keyframes tool-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}
/* Done state */
.chat-tool.done { color: var(--success); animation: tool-done-flash 0.4s ease-out; }
.chat-tool.done .tool-icon { display: inline-block; animation: tool-check-pop 0.3s ease-out; }
@keyframes tool-done-flash {
    0% { background: rgba(52,211,153,0.25); }
    100% { background: rgba(99,102,241,0.12); }
}
@keyframes tool-check-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.chat-tool-wrap { display: contents; }
.chat-tool-subtasks {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-left: 16px;
    border-left: 2px solid rgba(99,102,241,0.2);
    margin: 2px 0;
}
.chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.btn-action {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-action:hover {
    background: var(--accent);
    color: #fff;
}
/* File cards (share_files tool) */
.chat-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.file-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    max-width: 260px;
}
.file-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(99,102,241,0.15);
}
.file-card-icon { font-size: 20px; flex-shrink: 0; }
.file-card-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.file-card-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-card-size {
    font-size: 11px;
    color: var(--muted);
}
.file-card-dl {
    font-size: 0;
    color: var(--accent);
    cursor: pointer;
    padding: 4px 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid var(--accent);
    background: transparent;
    line-height: 1;
}
.file-card-dl::before {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='%236366f1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}
.file-card-dl:hover {
    background: var(--accent);
}
.file-card-dl:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
}
/* Email cards (chat) */
.email-card-wrap { padding: 2px 0; }
.email-card {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    max-width: 360px;
}
.email-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--muted);
}
.email-card-icon { font-size: 14px; opacity: 0.9; }
.email-card-dir { font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.email-card.outbound .email-card-dir { color: var(--success); }
.email-card.outbound.source-gmail .email-card-dir { color: #f59e0b; }
.email-card.outbound.source-imap .email-card-dir { color: #8b5cf6; }
.email-card.inbound .email-card-dir { color: #3b82f6; }
.email-card-failed { color: var(--danger); font-weight: 500; }
.email-card-source { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; padding: 1px 5px; border-radius: 3px; }
.email-card-source.gmail { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.email-card-source.imap { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.email-card-route { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 4px; overflow: hidden; }
.email-card-arrow { color: var(--muted); flex-shrink: 0; font-size: 11px; }
.email-card-addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.email-card-date { margin-left: auto; flex-shrink: 0; }
.email-card-field { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.email-card-label { font-weight: 600; color: var(--text); margin-right: 4px; }
.email-card-subject { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.email-card-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Activity cards (cron, webhook, telegram) */
.activity-card {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    max-width: 360px;
    margin: 4px 0;
}
.activity-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--muted);
}
.activity-card-icon { font-size: 13px; }
.activity-card-label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; font-size: 10px; }
.activity-card-time { margin-left: auto; font-size: 11px; color: var(--muted); }
.activity-card-body { font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.activity-card.cron .activity-card-label { color: #f59e0b; }
.activity-card.hook .activity-card-label { color: #ec4899; }
.activity-card.telegram .activity-card-label { color: #3b82f6; }

/* Channel badge on assistant bubbles */
.channel-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-bottom: 6px;
}
.channel-badge.telegram { background: rgba(59,130,246,0.15); color: #3b82f6; }
.channel-badge.email { background: rgba(34,197,94,0.15); color: #22c55e; }
.channel-badge.cron { background: rgba(245,158,11,0.15); color: #f59e0b; }
.channel-badge.hook { background: rgba(236,72,153,0.15); color: #ec4899; }

/* Muted automated assistant bubbles */
.chat-bubble.automated { opacity: 0.7; }

/* Email tab */
.email-list { display: flex; flex-direction: column; gap: 2px; }
.email-list-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
}
.email-list-row:hover { background: var(--surface); }
.email-list-icon { font-size: 16px; flex-shrink: 0; }
.email-list-addr { font-size: 13px; color: var(--text); font-weight: 500; min-width: 120px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.email-list-subject { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-list-failed { font-size: 11px; color: var(--danger); font-weight: 500; flex-shrink: 0; }
.email-list-date { font-size: 11px; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
.email-list-detail {
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}
.email-list-row:has(.email-list-detail) { flex-wrap: wrap; background: var(--surface); }
.email-detail-field { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.email-detail-field strong { color: var(--text); margin-right: 4px; }
.email-detail-body { font-size: 12px; color: var(--text); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); white-space: pre-wrap; }

/* Sidebar email panel */
.sidebar-email-list { display: flex; flex-direction: column; gap: 2px; }
.sidebar-email-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    padding: 2px 0;
}
.sidebar-email-row .email-list-icon { font-size: 12px; }
.sidebar-email-subject { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Page link cards (inline in markdown) */
.page-link-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-decoration: none !important;
    color: var(--text) !important;
    margin: 4px 0;
    max-width: 300px;
}
.page-link-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(99,102,241,0.15);
}
.page-link-icon { font-size: 18px; flex-shrink: 0; }
.page-link-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.page-link-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-link-type {
    font-size: 11px;
    color: var(--muted);
}
.page-link-open {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    flex-shrink: 0;
    padding: 2px 8px;
    border: 1px solid var(--accent);
    border-radius: 4px;
}
.page-link-card:hover .page-link-open {
    background: var(--accent);
    color: white;
}

.tool-icon { font-size: 10px; }
.tool-name { font-family: monospace; }
.typing-indicator {
    display: inline-block;
    color: var(--muted);
    animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.chat-error-banner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    color: #fca5a5;
}
.chat-error-banner.budget {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.25);
    color: #fcd34d;
}
.chat-error-banner.overloaded {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.25);
    color: #fcd34d;
}
.chat-error-banner.limit {
    background: rgba(156,163,175,0.1);
    border-color: rgba(156,163,175,0.25);
    color: #d1d5db;
}
.chat-error-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.chat-error-text strong { font-weight: 600; }
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-input-area textarea {
    flex: 1;
    resize: none;
    min-height: 56px;
    max-height: 200px;
    overflow-y: auto;
    padding: 14px 18px;
    font-size: 15px;
    line-height: 1.5;
    border-radius: 12px;
}
.chat-input-area .btn { align-self: flex-end; }

/* ── Send button (arrow-up icon) ── */
.btn-send {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    margin-right: 12px;
    transition: opacity 0.15s;
}
.btn-send::before {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 3 L10 16 M4 9 L10 3 L16 9' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}
.btn-send:hover { opacity: 0.85; }
.btn-send:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ── Loading ── */
.loading { color: var(--muted); padding: 20px 0; }

/* ── Landing ── */
body.landing {
    height: auto;
    overflow: visible;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body.landing nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border);
}
body.landing nav .logo { font-size: 18px; font-weight: 700; }

.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
}
.hero h1 { font-size: 48px; font-weight: 700; margin-bottom: 16px; letter-spacing: -1px; }
.hero p { font-size: 18px; color: var(--muted); max-width: 480px; margin-bottom: 32px; }
.subtext { color: var(--muted); font-size: 13px; margin-top: 12px; }

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 40px;
    border-top: 1px solid var(--border);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}
.feature h3 { font-size: 15px; margin-bottom: 8px; }
.feature p { color: var(--muted); font-size: 13px; }

body.legal-page {
    height: auto;
    overflow: visible;
    min-height: 100vh;
}

.landing-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px 40px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}
.landing-footer a { color: var(--muted); text-decoration: none; }
.landing-footer a:hover { color: var(--text-primary); }
.landing-footer .muted { color: var(--muted); opacity: 0.5; }

.sidebar-footer-links {
    display: flex;
    gap: 10px;
    font-size: 12px;
}
.sidebar-footer-links a { color: var(--muted); text-decoration: none; }
.sidebar-footer-links a:hover { color: var(--text-primary); }

/* ── Bot integrations ── */
.bot-integrations { display: flex; flex-direction: column; gap: 8px; }
.toggle-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; font-size: 13px;
}
.toggle-row:hover { border-color: var(--accent); }
.toggle-row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.toggle-row span:first-of-type { font-weight: 500; min-width: 120px; }
.toggle-desc { color: var(--muted); font-size: 12px; }
.integration-notice { color: var(--muted); font-size: 13px; padding: 12px 0; }
.integration-notice a { color: var(--accent); }
.saving-msg { color: var(--muted); font-size: 12px; padding-top: 4px; }

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

.detail-bot-name {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot.sm { width: 7px; height: 7px; }


/* ── Sub-page toolbar (e.g. Files actions) ── */
.sub-page-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.back-btn { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.back-btn svg { display: block; flex-shrink: 0; }
.detail-tab-label { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 4px; }

.detail-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.detail-chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 24px;
    position: relative;
}

.chat-offline {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 8px;
}

/* ── Detail sidebar ── */
.detail-sidebar {
    width: 300px;
    min-width: 260px;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
}

.sidebar-panel {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-panel[onclick],
.sidebar-panel.soul-panel,
.sidebar-panel.memory-panel,
.sidebar-panel.automations-panel,
.sidebar-panel.skills-panel,
.sidebar-panel.nav-panel {
    cursor: pointer;
    transition: background 0.1s;
    padding: 10px 14px;
}
.sidebar-panel.nav-panel:hover {
    background: rgba(255,255,255,0.04);
}
.sidebar-panel.nav-panel .sidebar-panel-header {
    margin-bottom: 0;
}
.sidebar-panel.nav-panel .sidebar-panel-header:not(:last-child) {
    margin-bottom: 6px;
}
.memory-preview.compact, .skills-list.compact {
    margin-top: 0;
}
.memory-preview.compact .memory-preview-line {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.skills-list.compact .skill-row {
    padding: 0;
    margin: 0;
}
.skills-list.compact .skill-name {
    font-size: 11px;
    color: var(--text);
}

.sidebar-panel-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 8px;
}

.panel-link {
    margin-left: auto;
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.panel-count {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    background: rgba(255,255,255,0.06);
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0;
    text-transform: none;
}

.panel-empty {
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}

.soul-preview { display: flex; flex-direction: column; gap: 3px; }
.soul-preview-line {
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.soul-preview-line:first-child { font-weight: 500; }
.soul-preview-line:not(:first-child) { color: var(--muted); }

.memory-preview { display: flex; flex-direction: column; gap: 2px; }
.memory-preview-line {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-panel .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 12px;
}
.stats-panel .stat-label { color: var(--muted); }
.stats-panel .stat-val { font-weight: 500; text-transform: capitalize; }
.stats-panel .stat-val.running { color: var(--running); }
.stats-panel .stat-val.paused { color: var(--paused); }
.stats-panel .stat-val.error { color: var(--error); }
.stat-link { color: var(--accent); cursor: pointer; font-size: 12px; text-transform: none; }
.stat-link:hover { text-decoration: underline; }
.stats-panel .stat-val.spend-ok { color: var(--success); }
.stats-panel .stat-val.spend-warn { color: var(--warn); }
.stats-panel .stat-val.spend-over { color: var(--danger); }

/* ── Limits panel ── */
.limits-panel .sidebar-panel-header:not(:last-child) { margin-bottom: 8px; }
.limit-row { margin-bottom: 8px; }
.limit-row:last-child { margin-bottom: 0; }
.limit-label-row { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; }
.limit-name { color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.limit-vals { color: var(--text); font-weight: 500; }
.limit-bar-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.limit-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; min-width: 1px; }
.limit-bar-fill.bar-ok { background: var(--success); }
.limit-bar-fill.bar-warn { background: var(--warn); }
.limit-bar-fill.bar-over { background: var(--danger); }
.limits-empty { font-size: 12px; color: var(--muted); }

/* ── Automations panel ── */
.automations-list { display: flex; flex-direction: column; gap: 3px; }
.automation-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
.automation-icon { font-size: 11px; width: 14px; text-align: center; flex-shrink: 0; }
.automation-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.automation-detail { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

/* ── Skills panel ── */
.skills-list { display: flex; flex-direction: column; gap: 3px; }
.page-row { display: flex; align-items: center; gap: 6px; font-size: 12px; text-decoration: none; color: var(--text); padding: 1px 0; }
.page-row:hover { color: var(--accent); }
.page-icon { font-size: 11px; flex-shrink: 0; }
.page-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pages-list { display: flex; flex-direction: column; gap: 2px; }

.skill-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.skill-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-detail { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

.skill-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s; }
.skill-card:hover { border-color: var(--accent); }
.skill-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.skill-card-desc { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.skill-card-path { font-size: 11px; color: var(--muted); font-family: monospace; }
.skill-card-header { cursor: pointer; }
.skill-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.skill-card-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.skill-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.skill-linked-badge { font-size: 11px; background: rgba(99,102,241,0.1); color: var(--accent); padding: 2px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.skill-linked-badge:hover { background: rgba(99,102,241,0.2); }
.skill-type-badge { font-size: 10px; padding: 1px 5px; border-radius: 3px; background: var(--border); color: var(--muted); font-family: monospace; font-weight: 500; }
.skill-type-js { background: rgba(234,179,8,0.15); color: #eab308; }
.skill-type-both { background: rgba(99,102,241,0.15); color: var(--accent); }

/* ── Skill editor modal ── */
.skill-editor-modal { width: 800px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column; }
.skill-editor-tabs { display: flex; gap: 4px; margin-right: 8px; }
.skill-editor-body { flex: 1; overflow: hidden; margin: 0 16px 16px; border: 1px solid var(--border); border-radius: 6px; }
.skill-editor-body .CodeMirror {
    height: 100%;
    min-height: 400px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--bg);
}
.skill-editor-body .CodeMirror-gutters { background: var(--surface); border-right: 1px solid var(--border); }
.skill-editor-body .CodeMirror-cursor { border-left-color: var(--text); }

.sidebar-meta-row {
    font-size: 12px;
    color: var(--muted);
    padding: 2px 0;
}
.integration-badge {
    display: inline-block;
    margin-right: 12px;
    color: var(--success);
    font-size: 11px;
}

/* ── Sub-pages (soul, memory, activity, settings) ── */
.sub-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}


.sub-page-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

.sub-page-desc {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.sub-page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

/* ── Files ── */
.files-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 24px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.breadcrumb-item { color: var(--muted); cursor: pointer; }
.breadcrumb-item:hover { color: var(--text); }
.breadcrumb-item.current { color: var(--text); font-weight: 500; }
.breadcrumb-sep { color: var(--muted); margin: 0 2px; }

.files-body { max-width: 100%; padding: 0; }

.file-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}
.file-row:hover { background: rgba(255,255,255,0.03); }
.file-icon { width: 20px; text-align: center; flex-shrink: 0; }
.file-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { width: 70px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.file-modified { width: 90px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.file-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 0.1s; }
.file-row:hover .file-actions { opacity: 1; }

.btn-inline {
    background: none; border: none; color: var(--muted); cursor: pointer;
    padding: 2px 6px; border-radius: 3px; font-size: 13px;
}
.btn-inline:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.btn-inline.danger:hover { color: var(--danger); }

/* ── Download SVG icon (reusable) ── */
.dl-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
}
.dl-icon::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}
.dl-icon:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='%23e8e8e8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
}
.tool-file-link.dl-icon { margin-left: 6px; }

.btn-sm { font-size: 12px; padding: 4px 10px; }

/* Inline file links in chat tool results */
.tool-file-sep { color: var(--muted); margin: 0 4px; }
.tool-file-name { font-family: monospace; font-size: 11px; color: var(--text); }
.tool-file-link { font-size: 11px; color: var(--accent); cursor: pointer; margin-left: 6px; }
.tool-file-link:hover { color: var(--accent-hover); text-decoration: underline; }

.file-viewer-size { font-size: 12px; color: var(--muted); }

.file-viewer-modal { width: 900px; max-width: 90vw; max-height: 80vh; display: flex; flex-direction: column; }
.file-viewer-content {
    flex: 1; overflow: auto; padding: 16px;
    font-family: monospace; font-size: 12px; line-height: 1.6;
    background: var(--bg); border-radius: 6px; margin: 0 16px 16px;
    white-space: pre-wrap; word-wrap: break-word;
}
.file-viewer-rendered {
    font-family: var(--font); font-size: 14px; white-space: normal;
}
.file-viewer-rendered h1, .file-viewer-rendered h2, .file-viewer-rendered h3,
.file-viewer-rendered h4, .file-viewer-rendered h5, .file-viewer-rendered h6 {
    margin: 1em 0 0.5em; color: var(--text);
}
.file-viewer-rendered h1 { font-size: 1.5em; }
.file-viewer-rendered h2 { font-size: 1.3em; }
.file-viewer-rendered h3 { font-size: 1.1em; }
.file-viewer-rendered p { margin: 0.5em 0; }
.file-viewer-rendered ul, .file-viewer-rendered ol { margin: 0.5em 0; padding-left: 1.5em; }
.file-viewer-rendered li { margin: 0.25em 0; }
.file-viewer-rendered code { background: var(--surface); padding: 2px 5px; border-radius: 3px; font-size: 0.9em; }
.file-viewer-rendered pre { white-space: pre-wrap; }
.file-viewer-rendered pre code { background: none; padding: 0; }
.file-viewer-rendered a { color: var(--accent); }
.file-viewer-rendered blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--muted); margin: 0.5em 0; }
.file-viewer-rendered table { border-collapse: collapse; margin: 0.5em 0; }
.file-viewer-rendered th, .file-viewer-rendered td { border: 1px solid var(--border); padding: 6px 10px; }
.file-viewer-rendered hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }

.raw-toggle {
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    display: block;
    margin-top: 8px;
    margin-bottom: 4px;
}
.raw-toggle:hover { color: var(--accent); }

.label-opt {
    color: var(--muted);
    font-weight: 400;
}

/* ── Activity ── */
.activity-group { margin-bottom: 24px; }

.activity-date {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.activity-daily-cost {
    font-weight: 600;
    font-size: 11px;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
}

/* Exchange rows */
.activity-exchange {
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.1s;
}
.activity-exchange:hover { background: rgba(99,102,241,0.06); }

.activity-exchange-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 8px;
    font-size: 12px;
}

.activity-time { color: var(--muted); min-width: 40px; font-size: 11px; flex-shrink: 0; }
.activity-channel {
    font-size: 10px;
    background: var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--muted);
    min-width: 26px;
    text-align: center;
    flex-shrink: 0;
    white-space: nowrap;
}
.activity-channel-cron { background: rgba(245,158,11,0.12); color: #b45309; }
.activity-channel-hook { background: rgba(99,102,241,0.12); color: #6366f1; }
.activity-dir { color: var(--muted); min-width: 14px; flex-shrink: 0; display: flex; align-items: center; }
.activity-dir svg { display: block; }
.activity-content { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.activity-user-text { color: var(--text); }
.activity-arrow { color: var(--muted); margin: 0 4px; font-size: 11px; }
.activity-bot-text { color: var(--muted); }
.activity-cost { color: var(--muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

/* Tool badges */
.activity-tools { display: flex; gap: 3px; flex-shrink: 0; }
.activity-tool-badge {
    font-size: 9px;
    font-family: var(--font-mono, monospace);
    background: rgba(99,102,241,0.1);
    color: #6366f1;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}

/* Expanded detail */
.activity-exchange-detail {
    padding: 8px 12px 10px 56px;
    font-size: 12px;
    border-left: 2px solid var(--border);
    margin-left: 20px;
    margin-bottom: 4px;
}
.activity-detail-msg { margin-bottom: 6px; }
.activity-detail-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 8px;
}
.activity-detail-in .activity-detail-text { color: var(--muted); }
.activity-detail-out .activity-detail-text { color: var(--text); white-space: pre-wrap; }
.activity-detail-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Automation rows (cron/hook) */
.activity-automation {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 12px;
}
.activity-automation:hover { background: rgba(0,0,0,0.02); }
.activity-status { font-size: 12px; flex-shrink: 0; }
.activity-status.status-ok { color: #22c55e; }
.activity-status.status-err { color: #ef4444; }
.activity-auto-detail { color: var(--muted); font-size: 11px; }
.activity-error { color: #ef4444; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Settings sections ── */
.settings-body { max-width: 860px; }

.settings-section {
    padding-top: 40px;
    padding-bottom: 40px;
    border-top: 1px solid var(--border);
}

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

.settings-section:last-child {
    padding-bottom: 0;
}

.settings-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 24px;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.channel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.channel-row:last-child { border-bottom: none; }
.channel-info { display: flex; flex-direction: column; gap: 2px; }
.channel-name { font-size: 13px; font-weight: 500; }
.channel-desc { font-size: 12px; }

.telegram-connect-form { display: flex; gap: 8px; align-items: center; }

.badge-ok { background: rgba(34,197,94,0.12); color: var(--success); }
.badge-muted { background: var(--border); color: var(--muted); }

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

/* ── Schedule jobs ── */
.schedule-job-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.btn-sm:hover:not(:disabled) { border-color: var(--accent); }
.btn-sm:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-sm.btn-ghost { background: transparent; border-color: transparent; }
.badge-off { background: var(--border); color: var(--muted); padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; }

/* ── Trigger webhook URL ── */
.trigger-url {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.trigger-url code {
    font-family: 'SF Mono', SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

/* ── Container log panel ── */
.log-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
}
.log-panel-header:hover { border-color: var(--muted); }
.log-panel-toggle { color: var(--muted); font-size: 14px; }

.bot-log-panel {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #111;
    max-height: 420px;
    overflow-y: auto;
}

.bot-log-panel .log-content {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 1.55;
    padding: 12px 14px;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
}

.bot-log-panel .log-empty {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

.log-timestamp { color: #555; }
.log-line-error { color: #ef4444; }
.log-line-agent { color: #22c55e; }
.log-line-scheduler { color: #60a5fa; }
.log-line-hook { color: #f59e0b; }

.danger-zone .settings-section-title { color: var(--danger); }

.danger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px;
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 8px;
    background: rgba(239,68,68,0.04);
}
.danger-row + .danger-row { margin-top: 12px; }

.danger-label { font-size: 13px; font-weight: 500; margin-bottom: 4px; }

/* ── Toasts ── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    background: var(--surface);
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateX(40px);
    animation: toast-in 0.25s ease forwards;
    max-width: 320px;
}
.toast.toast-out {
    animation: toast-out 0.2s ease forwards;
}
.toast.success { background: var(--success); border-color: var(--success); }
.toast.error { background: var(--danger); border-color: var(--danger); }
.toast.info { background: var(--accent); border-color: var(--accent); }
@keyframes toast-in {
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Billing ── */
.sidebar-account {
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.sidebar-account-info {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.1s;
}
.sidebar-account-info:hover { background: rgba(255,255,255,0.03); }

.sidebar-account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tier-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--border);
    color: var(--muted);
}
.tier-badge.pro { background: rgba(99,102,241,0.2); color: var(--accent); }

.sidebar-balance {
    font-size: 13px;
    font-weight: 600;
}

/* Welcome card */
.welcome-card {
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}
.welcome-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}
.welcome-plan {
    font-size: 14px;
    margin-bottom: 8px;
}
.welcome-explain {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 20px;
    line-height: 1.5;
}
.welcome-actions {
    display: flex;
    gap: 10px;
}

.billing-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.billing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
}

.billing-card-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 12px;
}

.credit-balance {
    font-size: 32px;
    font-weight: 700;
}
.credit-balance.balance-ok { color: var(--success); }
.credit-balance.balance-low { color: var(--warn); }
.credit-balance.balance-zero { color: var(--danger); }

.credit-packs {
    display: flex;
    gap: 12px;
}

.credit-pack-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.credit-pack-card:hover { border-color: var(--accent); }

.credit-pack-amount {
    font-size: 20px;
    font-weight: 600;
}

.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }

.usage-range-btns { display: flex; gap: 4px; }
.usage-summary { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* ── Mobile back button (hidden on desktop) ── */
.mobile-back { display: inline-flex; }

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVE — max-width: 768px
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Mobile back button ── */
    .mobile-back {
        display: inline-flex;
        font-size: 18px;
        padding: 4px 8px;
    }

    /* ── Left sidebar: hide when a bot is selected ── */
    #app:has(.bot-detail) .sidebar { display: none; }

    /* When sidebar IS visible (no bot selected, or nav pages), go full-width */
    .sidebar {
        width: 100%;
        min-width: 0;
    }

    /* Larger touch targets for bot list items */
    .sidebar-bot-item {
        padding: 10px 12px;
        font-size: 14px;
    }

    .sidebar-nav a {
        padding: 12px 12px;
        font-size: 14px;
    }

    /* ── Main content: reduce padding ── */
    .main {
        padding: 16px;
    }

    /* ── Detail header: compact ── */
    .detail-header {
        padding: 10px 12px;
        gap: 8px;
    }

    /* ── Right sidebar: hide on mobile ── */
    .detail-sidebar {
        display: none;
    }

    /* ── Chat area: tighter padding ── */
    .detail-chat {
        padding: 8px 12px;
    }

    /* Chat bubbles: wider on mobile */
    .chat-bubble {
        max-width: 90%;
    }

    /* Prevent iOS zoom on textarea focus */
    .chat-input-area textarea {
        font-size: 16px;
    }

    /* ── Sub-pages: reduce padding ── */
    .sub-page-body {
        padding: 16px;
    }

    .sub-page-toolbar {
        padding: 10px 12px;
    }

    /* ── Settings: touch-friendly inputs ── */
    .settings-form input,
    .settings-form select,
    .settings-form textarea,
    .settings-form .btn {
        min-height: 44px;
    }

    .toggle-row {
        padding: 12px;
        min-height: 44px;
    }

    /* ── Files: reduce padding ── */
    .file-row {
        padding: 10px 12px;
    }

    .files-breadcrumbs {
        padding: 8px 12px;
    }

    /* Hide less-important file columns on mobile */
    .file-size,
    .file-modified {
        display: none;
    }

    /* File actions always visible on mobile (no hover) */
    .file-actions {
        opacity: 1;
    }

    /* ── Settings rows: stack vertically ── */
    .settings-form-inline .settings-row {
        flex-direction: column;
        gap: 0;
    }

    /* ── Danger zone: stack ── */
    .danger-row {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    /* ── Integrations: compact ── */
    .integration-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .integration-products { grid-template-columns: repeat(2, 1fr); }

    /* ── Chat welcome: tighter ── */
    .chat-welcome {
        padding: 30px 12px 20px;
    }

    .chat-welcome-chips {
        max-width: 100%;
    }

    /* ── Billing: stack credit packs ── */
    .credit-packs {
        flex-direction: column;
    }

    /* ── Landing page: responsive ── */
    .hero h1 { font-size: 32px; }
    .hero p { font-size: 16px; }
    .features { grid-template-columns: 1fr; padding: 24px 16px; }
    body.landing nav { padding: 16px 20px; }

    /* ── Modal: full-width on mobile ── */
    .modal {
        width: 100%;
        max-width: 100vw;
        border-radius: 12px 12px 0 0;
        margin: auto 0 0 0;
    }

    .skill-editor-modal {
        width: 100%;
        max-height: 95vh;
    }

    .file-viewer-modal {
        width: 100%;
        max-height: 90vh;
    }

    /* ── Toasts: center on mobile ── */
    .toast-container {
        right: 12px;
        left: 12px;
        bottom: 12px;
    }

    .toast {
        max-width: 100%;
    }

    /* ── Trigger URL: allow wrapping ── */
    .trigger-url code {
        max-width: 100%;
        white-space: normal;
        word-break: break-all;
    }

    /* ── Schedule job rows: wrap ── */
    .schedule-job-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* ── Telegram connect form: stack ── */
    .telegram-connect-form {
        flex-direction: column;
        align-items: stretch;
    }

    /* ── Channel rows: stack on mobile ── */
    .channel-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .dashboard-kpis { grid-template-columns: repeat(2, 1fr); }
    .dashboard-bottom { grid-template-columns: 1fr; }
    .dashboard-table-wrap { overflow-x: auto; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Fleet Dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

.fleet-dashboard {
    height: 100%;
    overflow-y: auto;
    padding: 0;
}

.fleet-dashboard .empty-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.dashboard-content {
    max-width: 920px;
    margin: 0 auto;
    padding: 40px 28px 48px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.dashboard-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.dashboard-period {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}
.dashboard-period .btn-xs {
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 4px;
    color: var(--muted);
}
.dashboard-period .btn-xs.active {
    background: var(--accent);
    color: white;
}

/* KPI Cards */
.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.kpi-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}
.kpi-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}
.kpi-sub {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.kpi-tag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
}
.kpi-tag.running { background: rgba(34,197,94,0.15); color: #22c55e; }
.kpi-tag.paused { background: rgba(245,158,11,0.15); color: #f59e0b; }
.kpi-tag.error { background: rgba(239,68,68,0.15); color: #ef4444; }
.kpi-tag.deleted { background: rgba(136,136,136,0.15); color: #888; }

.kpi-cost { color: var(--accent); }
.kpi-balance-ok { color: var(--success); }
.kpi-balance-low { color: var(--warn); }
.kpi-sub.muted-sub { color: var(--muted); }

.tier-badge.sm {
    font-size: 9px;
    padding: 1px 5px;
}

/* Bot table */
.dashboard-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
}
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.dashboard-table thead th {
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.dashboard-table thead th.num { text-align: right; }
.dashboard-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.dashboard-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dashboard-table tbody tr:last-child td { border-bottom: none; }
.dashboard-row { cursor: pointer; transition: background 0.1s; }
.dashboard-row:hover { background: rgba(99,102,241,0.05); }

.bot-name-cell { font-weight: 500; }

.status-label { font-size: 12px; }
.status-label.running { color: var(--success); }
.status-label.paused { color: var(--warn); }
.status-label.error { color: var(--danger); }
.status-label.provisioning { color: var(--muted); }

.budget-bar-wrap {
    display: inline-block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 6px;
}
.budget-bar {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}
.budget-bar.warn { background: var(--warn); }

.channels-cell { display: flex; gap: 4px; }
.channel-tag {
    font-size: 10px;
    font-weight: 600;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    background: rgba(99,102,241,0.1);
    color: var(--accent);
}

/* Bottom row: chart + channels */
.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 24px;
}
.dashboard-chart, .dashboard-channels {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.dashboard-chart-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 10px;
}

/* Sparkline */
.sparkline-wrap { position: relative; }
.sparkline-svg {
    width: 100%;
    height: 40px;
    display: block;
}
.sparkline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
}

/* Channel bars */
.channel-bars { display: flex; flex-direction: column; gap: 8px; }
.channel-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.channel-bar-label {
    width: 60px;
    text-transform: capitalize;
    color: var(--muted);
}
.channel-bar-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.channel-bar-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}
.channel-bar-pct {
    width: 32px;
    text-align: right;
    color: var(--muted);
    font-size: 11px;
}

/* Recent Activity */
.dashboard-activity {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.fleet-activity-list {
    display: flex;
    flex-direction: column;
}
.fleet-activity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
    font-size: 13px;
}
.fleet-activity-row:last-child { border-bottom: none; }
.fleet-activity-row:hover { background: rgba(99,102,241,0.05); border-radius: 6px; }
.fleet-activity-bot {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    min-width: 70px;
    flex-shrink: 0;
}
.fleet-activity-text {
    flex: 1;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fleet-activity-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.fleet-activity-channel {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}
.fleet-activity-channel.web { background: rgba(99,102,241,0.12); color: #818cf8; }
.fleet-activity-channel.telegram { background: rgba(34,197,94,0.12); color: #22c55e; }
.fleet-activity-channel.cron { background: rgba(245,158,11,0.12); color: #f59e0b; }
.fleet-activity-channel.hook { background: rgba(236,72,153,0.12); color: #ec4899; }
.fleet-activity-time {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    min-width: 50px;
    text-align: right;
}
