/* BBG Ops Hub — Dark theme, mobile-first */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21242f;
    --bg-input: #2a2d3a;
    --border: #2e3244;
    --text-primary: #e4e6ed;
    --text-secondary: #9298a8;
    --text-muted: #6b7186;
    --accent: #4f8ff7;
    --accent-hover: #3a7ce6;
    --green: #34d399;
    --yellow: #fbbf24;
    --red: #f87171;
    --blue: #60a5fa;
    --orange: #fb923c;
    --sidebar-width: 220px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Top Navigation */
.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 6px 16px;
    min-height: 48px;
    gap: 8px;
    flex-wrap: wrap;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topnav-logo {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary) !important;
    white-space: nowrap;
}

.topnav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    flex-wrap: wrap;
    padding: 0 8px;
}

.topnav-links a {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    border-radius: 5px;
    transition: all 0.15s;
}

.topnav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.topnav-links a.active {
    color: var(--accent);
    background: rgba(79, 143, 247, 0.12);
}

.topnav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topnav-logout {
    font-size: 12px;
    color: var(--text-muted) !important;
    padding: 4px 8px;
}

.topnav-logout:hover { color: var(--text-secondary) !important; }

/* Content — no sidebar offset */
.content-top {
    flex: 1;
    min-height: calc(100vh - 48px);
}

.topbar {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar h1 { font-size: 18px; font-weight: 600; }

.page-content { padding: 24px; }

/* Auth page */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 { font-size: 24px; margin-bottom: 4px; text-align: center; }
.auth-subtitle { color: var(--text-muted); text-align: center; margin-bottom: 24px; font-size: 14px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }

input[type="text"], input[type="password"], select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

input:focus, select:focus { outline: none; border-color: var(--accent); }

.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form .form-group { flex: 1; min-width: 200px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:hover { background: var(--bg-input); border-color: var(--text-muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-warning { background: var(--orange); border-color: var(--orange); color: #000; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.card h3 { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

/* Status */
.status-grid { display: flex; flex-direction: column; gap: 8px; }

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

.status-label { margin-left: auto; font-size: 12px; color: var(--text-muted); }

/* Big numbers */
.big-number { font-size: 48px; font-weight: 700; line-height: 1; margin-bottom: 12px; }

.card-details { display: flex; flex-direction: column; gap: 4px; }
.detail-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); }
.detail-row .count { font-weight: 600; color: var(--text-primary); }

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.alert-error { background: rgba(248, 113, 113, 0.1); border: 1px solid var(--red); color: var(--red); }
.alert-success { background: rgba(52, 211, 153, 0.1); border: 1px solid var(--green); color: var(--green); }
.alert-warning { background: rgba(251, 191, 36, 0.1); border: 1px solid var(--yellow); color: var(--yellow); }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.badge-red { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.badge-yellow { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }
.badge-green { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.badge-blue { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.badge-daily { background: rgba(79, 143, 247, 0.15); color: var(--accent); }
.badge-weekly { background: rgba(52, 211, 153, 0.15); color: var(--green); }

.badge-info { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.badge-error { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.badge-warning { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }

/* Tables */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover { background: rgba(79, 143, 247, 0.03); }

.age-yellow td { color: var(--yellow); }
.age-red td { color: var(--red); }

.empty-state { text-align: center; color: var(--text-muted); padding: 32px !important; }

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

/* Tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }

.tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.tab:hover { background: var(--bg-card); color: var(--text-primary); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Stock */
.stock-section { margin-bottom: 20px; }

.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.stock-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
}

.stock-red { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.3); }
.stock-yellow { background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.3); }
.stock-blue { background: rgba(96, 165, 250, 0.1); border: 1px solid rgba(96, 165, 250, 0.3); }

.stock-name { font-weight: 500; }
.stock-qty { font-weight: 700; font-size: 15px; }

.stock-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    margin: 4px;
}

/* Section titles */
.section-title { font-size: 15px; font-weight: 600; margin: 24px 0 12px; }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue { color: var(--blue); }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* Issues */
.issue-list { list-style: none; }
.issue-list li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); }
.issue-list li:last-child { border: none; }

.all-clear { color: var(--green); font-weight: 600; font-size: 15px; }

/* Logs */
.log-selector { margin-bottom: 12px; }
.log-selector select { max-width: 400px; }

.log-output, .brief-text {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 500px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.log-table-container { max-height: 400px; overflow-y: auto; }

.log-info td:nth-child(2) .badge { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.log-error td:nth-child(2) .badge { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.log-warning td:nth-child(2) .badge { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }

/* Brief */
.brief-section { margin-bottom: 24px; }
.brief-box { margin-top: 8px; }

.history-list { display: flex; flex-direction: column; gap: 6px; }

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 13px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* Hamburger */
.hamburger {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    display: none;
}

/* Mobile */
@media (max-width: 768px) {
    .topnav {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
    }

    .topnav-links {
        display: none;
        flex-basis: 100%;
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px 0 4px;
        order: 3;
    }

    .topnav-links.open { display: flex; }

    .hamburger { display: block; }
    .mobile-only { display: block !important; }

    .card-grid { grid-template-columns: 1fr; }
    .stock-grid { grid-template-columns: 1fr; }

    .page-content { padding: 16px; }

    .inline-form { flex-direction: column; }
    .inline-form .form-group { min-width: 100%; }

    .auth-card { margin: 16px; padding: 24px; }
}

.mobile-only { display: none; }

/* Recommendations */
.rec-card {
    position: relative;
    padding-left: 24px;
}

.rec-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 2px;
}

.rec-approved::before { background: var(--green); }
.rec-rejected { opacity: 0.5; }
.rec-later::before { background: var(--yellow); }
.rec-pending::before { background: var(--accent); }

.rec-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.rec-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.rec-impact { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.rec-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.rec-actions { display: flex; gap: 6px; margin-top: 10px; }
.rec-decided { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.rec-notes { font-size: 13px; margin-top: 10px; padding: 10px; background: rgba(255,255,255,0.03); border-radius: 6px; border-left: 3px solid var(--accent); }
.rec-notes p { margin: 4px 0 8px 0; color: var(--text-secondary); white-space: pre-wrap; }
.rec-notes-form { margin-top: 10px; }
.rec-notes-input { width: 100%; background: var(--bg-input); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: inherit; resize: vertical; margin-bottom: 6px; box-sizing: border-box; }
.rec-notes-input:focus { outline: none; border-color: var(--accent); }
.rec-notes-input::placeholder { color: var(--text-muted); }

.btn-approve { background: rgba(52, 211, 153, 0.15); border-color: var(--green); color: var(--green); }
.btn-approve:hover { background: rgba(52, 211, 153, 0.25); }
.btn-reject { background: rgba(107, 113, 134, 0.15); border-color: var(--text-muted); color: var(--text-muted); }
.btn-reject:hover { background: rgba(107, 113, 134, 0.25); }
.btn-later { background: rgba(251, 191, 36, 0.15); border-color: var(--yellow); color: var(--yellow); }
.btn-later:hover { background: rgba(251, 191, 36, 0.25); }
.btn-revert { background: var(--bg-input); color: var(--text-muted); font-size: 11px; }

/* Project cards */
.project-card-link { text-decoration: none; color: inherit; }
.project-card-link:hover { color: inherit; }
.project-card-link:hover .card { border-color: var(--accent); }
.project-card { position: relative; cursor: pointer; transition: border-color 0.15s; }
.project-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.project-name { font-size: 16px; font-weight: 600; }
.project-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.project-status { font-size: 13px; margin-bottom: 8px; }
.project-next { font-size: 13px; color: var(--text-muted); }
.project-components-preview { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.project-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12px; color: var(--text-muted); }

/* Project detail */
.proj-summary { font-size: 15px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 16px; }

.proj-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.proj-meta-item { padding: 10px 14px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; }
.proj-meta-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }
.proj-meta-value { font-size: 13px; color: var(--text-primary); }

.proj-arch-section { margin-bottom: 20px; }
.proj-arch-section:last-child { margin-bottom: 0; }

.proj-tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.proj-tag { display: inline-block; padding: 4px 12px; background: rgba(79, 143, 247, 0.1); border: 1px solid rgba(79, 143, 247, 0.3); border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--accent); }

.proj-model-list { display: flex; flex-direction: column; gap: 6px; }
.proj-model-item { padding: 8px 12px; background: rgba(52, 211, 153, 0.05); border: 1px solid rgba(52, 211, 153, 0.2); border-radius: 6px; font-size: 13px; color: var(--text-secondary); }

.proj-decisions { display: flex; flex-direction: column; gap: 6px; }
.proj-decision-item { padding: 8px 12px; background: var(--bg-primary); border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; font-size: 13px; color: var(--text-secondary); }

.proj-build-story { font-size: 14px; line-height: 1.7; color: var(--text-secondary); }

/* SOPs */
.proj-sop-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.proj-sop-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; }
.proj-sop-number { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; background: var(--accent); color: #fff; border-radius: 50%; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.proj-sop-text { flex: 1; font-size: 13px; }

.proj-add-form { display: flex; gap: 8px; margin-top: 12px; }
.proj-add-form input { flex: 1; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); font-size: 13px; }
.proj-add-form input:focus { outline: none; border-color: var(--accent); }

/* Resources */
.proj-resource-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.proj-resource-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; }
.proj-resource-main { flex: 1; }
.proj-resource-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.proj-resource-title { font-size: 14px; font-weight: 500; }
.proj-resource-relevance { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.proj-resource-date { font-size: 11px; margin-top: 4px; }

.proj-resource-form { margin-top: 12px; }
.proj-resource-form-row { display: flex; gap: 8px; margin-bottom: 8px; }
.proj-resource-form-row input, .proj-resource-form-row select { padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); font-size: 13px; }
.proj-resource-form-row input:focus, .proj-resource-form-row select:focus { outline: none; border-color: var(--accent); }

@media (max-width: 768px) {
    .proj-meta-grid { grid-template-columns: 1fr; }
    .proj-resource-form-row { flex-direction: column; }
    .proj-resource-form-row select { flex: 1 !important; }
}

/* Filter stats */
.filter-stats { display: flex; gap: 16px; margin-bottom: 16px; }
.filter-stat { font-size: 13px; color: var(--text-muted); }
.filter-stat strong { color: var(--text-primary); }

/* Employees */
.emp-card-link { text-decoration: none; color: inherit; }
.emp-card-link:hover { color: inherit; }
.emp-card-link:hover .card { border-color: var(--accent); }
.emp-card { cursor: pointer; transition: border-color 0.15s; }

.emp-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.emp-name { font-size: 15px; font-weight: 600; }
.emp-role { font-size: 13px; color: var(--text-muted); }
.emp-dept { display: flex; gap: 6px; margin-bottom: 8px; }
.emp-summary { font-size: 13px; color: var(--text-secondary); }

.emp-avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.emp-avatar-human { background: rgba(79, 143, 247, 0.2); color: var(--accent); }
.emp-avatar-ai { background: rgba(52, 211, 153, 0.2); color: var(--green); }
.emp-avatar-worker { background: rgba(251, 191, 36, 0.2); color: var(--yellow); }

.emp-avatar-lg { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; flex-shrink: 0; }

.emp-profile { display: flex; align-items: flex-start; gap: 20px; }
.emp-profile-info { flex: 1; }

.emp-flow { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.emp-flow-step { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; background: var(--bg-primary); border-left: 2px solid var(--accent); font-size: 13px; color: var(--text-secondary); }
.emp-flow-num { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; background: var(--accent); color: #fff; border-radius: 50%; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.emp-config-grid { display: flex; flex-direction: column; gap: 8px; }
.emp-config-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.emp-config-item:last-child { border: none; }
.emp-config-key { font-weight: 600; color: var(--text-secondary); min-width: 140px; flex-shrink: 0; text-transform: capitalize; }
.emp-config-value { color: var(--text-primary); }
.emp-config-subitem { display: flex; gap: 12px; padding: 2px 0; }
.emp-config-subitem span { font-size: 12px; }

@media (max-width: 768px) {
    .emp-profile { flex-direction: column; align-items: center; text-align: center; }
    .emp-config-item { flex-direction: column; gap: 4px; }
    .emp-config-key { min-width: auto; }
}

/* Consumption */
.cons-process-name { font-weight: 500; }
.cons-mem { font-weight: 600; font-size: 13px; }

.cons-note-form { display: flex; gap: 8px; margin-bottom: 16px; }
.cons-note-input { flex: 1; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); font-size: 13px; }
.cons-note-input:focus { outline: none; border-color: var(--accent); }

.cons-notes-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cons-note-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; gap: 12px; }
.cons-note-text { font-size: 13px; flex: 1; }
.cons-note-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Activity Feed */
.activity-timeline { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.activity-icon-order { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.activity-icon-system { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.activity-icon-project { background: rgba(79, 143, 247, 0.15); color: var(--accent); }
.activity-icon-agent { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
.activity-icon-task { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }
.activity-body { flex: 1; }
.activity-title { font-size: 13px; font-weight: 500; }
.activity-detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.activity-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* Ops Score */
.score-card { text-align: center; }
.score-ring { position: relative; width: 120px; height: 120px; margin: 0 auto 12px; }
.score-number { font-size: 36px; font-weight: 700; line-height: 120px; }
.score-grade { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.score-grade-a { color: var(--green); }
.score-grade-b { color: var(--blue); }
.score-grade-c { color: var(--yellow); }
.score-grade-d { color: var(--red); }
.score-breakdown { display: flex; flex-direction: column; gap: 6px; text-align: left; margin-top: 12px; }
.score-metric { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.score-metric-bar { flex: 1; height: 4px; background: var(--bg-input); border-radius: 2px; margin: 0 8px; }
.score-metric-fill { height: 100%; border-radius: 2px; }
.score-fill-green { background: var(--green); }
.score-fill-yellow { background: var(--yellow); }
.score-fill-red { background: var(--red); }

/* Command Center */
.cmd-btn { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; color: var(--accent); font-size: 12px; font-weight: 500; cursor: pointer; }
.cmd-btn:hover { background: var(--bg-input); }

.cmd-drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 320px; background: var(--bg-secondary); border-left: 1px solid var(--border); z-index: 200; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.2s ease; }
.cmd-drawer.open { transform: translateX(0); }
.cmd-drawer-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cmd-drawer-header h3 { font-size: 15px; font-weight: 600; }
.cmd-close { background: none; border: none; color: var(--text-primary); font-size: 20px; cursor: pointer; }

.cmd-grid { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; }
.cmd-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color 0.15s; }
.cmd-item:hover { border-color: var(--accent); }
.cmd-item-icon { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.cmd-item-info { flex: 1; }
.cmd-item-name { font-size: 13px; font-weight: 500; }
.cmd-item-desc { font-size: 11px; color: var(--text-muted); }
.cmd-result { padding: 12px; margin-top: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }

@media (max-width: 768px) {
    .cmd-drawer { width: 100%; }
}

/* Recommendation lifecycle */
.rec-in_progress::before { background: var(--blue); }
.rec-completed::before { background: var(--green); }
.rec-completed { opacity: 0.7; }
.rec-progress-indicator { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.btn-start { background: rgba(96, 165, 250, 0.15); border-color: var(--blue); color: var(--blue); }
.btn-start:hover { background: rgba(96, 165, 250, 0.25); }

/* HTMX indicator */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* Session Handoff */
.handoff-done { font-size: 13px; color: var(--text-secondary); padding: 4px 0; }
.handoff-pending { font-size: 13px; padding: 4px 0; }
.handoff-next { font-size: 13px; font-weight: 500; color: var(--accent); padding: 8px 12px; background: rgba(79, 143, 247, 0.08); border-radius: 6px; margin-top: 8px; }

/* Changelog */
.changelog-group { margin-bottom: 24px; }
.changelog-date { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }
.changelog-entry { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.changelog-entry:last-child { border: none; }
.changelog-session { font-size: 11px; color: var(--text-muted); flex-shrink: 0; min-width: 70px; }
.changelog-text { color: var(--text-secondary); }

/* Cost Tracker */
.cost-bar-container { display: flex; flex-direction: column; gap: 8px; }
.cost-bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cost-bar-label { min-width: 100px; color: var(--text-secondary); }
.cost-bar { flex: 1; height: 20px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.cost-bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.3s; }
.cost-bar-amount { min-width: 80px; text-align: right; font-weight: 600; }

/* Research Suggestions */
.suggestion-card { padding: 12px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; }
.suggestion-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.suggestion-title { font-size: 14px; font-weight: 500; }
.suggestion-query { font-size: 12px; color: var(--accent); margin-top: 4px; font-family: monospace; }
.suggestion-relevance { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Sales Module */
.sales-tab { }
.hidden { display: none !important; }
.tab-sm { padding: 4px 10px; font-size: 12px; }

.approval-card { margin-bottom: 12px; }
.approval-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.approval-context { font-size: 12px; margin-bottom: 8px; }
.approval-message { background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-size: 13px; line-height: 1.5; margin-bottom: 12px; white-space: pre-wrap; }
.approval-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.approval-edit { margin-top: 8px; }
.approval-notes { margin-top: 8px; font-size: 13px; }
.approval-notes details summary { cursor: pointer; }

.btn-approve { background: var(--green); color: #000; border-color: var(--green); }
.btn-approve:hover { background: #2bc48a; }
.btn-reject { background: var(--red); color: #fff; border-color: var(--red); }
.btn-reject:hover { background: #e05656; }

.form-input { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; color: var(--text-primary); font-size: 13px; font-family: inherit; resize: vertical; }
.form-input:focus { outline: none; border-color: var(--accent); }

.text-green { color: var(--green); font-size: 12px; }

.dot-blue { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.dot-grey { background: var(--text-muted); }
.badge-grey { background: var(--text-muted); color: #fff; }

.stat-card { text-align: center; padding: 16px; }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1.2; color: var(--text-primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== Brain Map v2 — Game UI ===== */

@keyframes brainSlideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes brainPulse { 0%, 100% { box-shadow: 0 0 8px rgba(79, 143, 247, 0.3); } 50% { box-shadow: 0 0 20px rgba(79, 143, 247, 0.6); } }
@keyframes brainFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Hero banner */
.brain-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(79,143,247,0.12), rgba(52,211,153,0.08));
    border: 1px solid rgba(79,143,247,0.25);
    border-radius: 12px;
    margin-bottom: 16px;
}

.brain-hero-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79,143,247,0.4), rgba(79,143,247,0.1));
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    animation: brainPulse 3s ease-in-out infinite;
    flex-shrink: 0;
}

.brain-hero-info { flex: 1; }
.brain-hero-name { font-size: 18px; font-weight: 700; }
.brain-hero-subtitle { font-size: 12px; color: var(--text-muted); }

.brain-hero-stats { display: flex; gap: 20px; }
.brain-hstat { text-align: center; }
.brain-hstat-val { display: block; font-size: 22px; font-weight: 700; color: var(--text-primary); }
.brain-hstat-key { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* XP bar */
.brain-xp-bar {
    position: relative;
    height: 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 11px;
    margin-bottom: 24px;
    overflow: hidden;
}

.brain-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 11px;
    transition: width 1s ease;
}

.brain-xp-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Skill tree grid */
.brain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.brain-skill-node {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.brain-skill-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--skill-color);
    opacity: 0.5;
    transition: opacity 0.2s;
}

.brain-skill-node:hover {
    border-color: var(--skill-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.brain-skill-node:hover::before { opacity: 1; }

.brain-skill-active {
    border-color: var(--skill-color) !important;
    box-shadow: 0 0 24px color-mix(in srgb, var(--skill-color) 25%, transparent),
                inset 0 0 30px color-mix(in srgb, var(--skill-color) 5%, transparent) !important;
}

.brain-skill-active::before { opacity: 1; height: 4px; }

.brain-skill-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.brain-skill-icon { font-size: 26px; }

.brain-skill-badge-auto {
    font-size: 8px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--green);
    color: #000;
    letter-spacing: 0.5px;
}

.brain-skill-name { font-size: 12px; font-weight: 600; margin-bottom: 8px; }

.brain-skill-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.brain-skill-fill {
    height: 100%;
    background: var(--skill-color);
    border-radius: 2px;
    transition: width 0.8s ease;
}

.brain-skill-meta { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); }
.brain-skill-lvl { font-weight: 700; color: var(--skill-color); }

/* Zone (expanded area) */
.brain-zone { animation: brainFadeIn 0.3s ease; }

.brain-zone-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.brain-zone-empty-icon { font-size: 48px; margin-bottom: 12px; }
.brain-zone-hint { font-size: 12px; margin-top: 6px; opacity: 0.6; }

/* Zone header */
.brain-zone-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--skill-color);
    border-radius: 8px;
    margin-bottom: 16px;
    animation: brainSlideDown 0.3s ease;
}

.brain-zone-title { display: flex; align-items: center; gap: 12px; }
.brain-zone-icon { font-size: 28px; }
.brain-zone-title h3 { font-size: 16px; font-weight: 600; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.brain-zone-title p { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }

.brain-zone-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.brain-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-muted);
}

.brain-tag-on { background: rgba(52,211,153,0.15); color: var(--green); }
.brain-tag-lazy { background: rgba(96,165,250,0.15); color: var(--blue); }

/* File card grid */
.brain-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.brain-fcard {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
    animation: brainSlideDown 0.3s ease;
    animation-fill-mode: both;
}

.brain-fcard:nth-child(1) { animation-delay: 0s; }
.brain-fcard:nth-child(2) { animation-delay: 0.05s; }
.brain-fcard:nth-child(3) { animation-delay: 0.1s; }
.brain-fcard:nth-child(4) { animation-delay: 0.15s; }
.brain-fcard:nth-child(5) { animation-delay: 0.2s; }
.brain-fcard:nth-child(6) { animation-delay: 0.25s; }
.brain-fcard:nth-child(n+7) { animation-delay: 0.3s; }

.brain-fcard:hover {
    border-color: var(--skill-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.brain-fcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.brain-fcard-title { font-size: 14px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }

.brain-fcard-auto {
    font-size: 8px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 3px;
    background: var(--green);
    color: #000;
    flex-shrink: 0;
}

.brain-fcard-tldr {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.brain-fcard-items { display: flex; flex-direction: column; gap: 3px; }

.brain-fcard-item {
    font-size: 11px;
    color: var(--text-muted);
    padding: 3px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brain-fcard-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.brain-fcard-depth { display: flex; gap: 3px; }

.brain-depth-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.brain-depth-filled { border-color: transparent; }

.brain-fcard-words { font-size: 10px; color: var(--text-muted); }
.brain-fcard-sections { font-size: 10px; color: var(--text-muted); margin-left: auto; }

/* File zone */
.brain-file-zone { margin-top: 16px; animation: brainSlideDown 0.3s ease; }

.brain-file-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    animation: brainSlideDown 0.3s ease;
}

.brain-file-error {
    padding: 16px;
    background: rgba(248,113,113,0.1);
    border: 1px solid var(--red);
    border-radius: 8px;
    color: var(--red);
    font-size: 13px;
}

.brain-file-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.brain-file-title-row { display: flex; align-items: baseline; gap: 10px; }
.brain-file-title-row h3 { font-size: 16px; font-weight: 600; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.brain-file-actions { display: flex; gap: 6px; }

/* TL;DR banner */
.brain-tldr-banner {
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(79,143,247,0.08), rgba(52,211,153,0.05));
    border: 1px solid rgba(79,143,247,0.2);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.brain-tldr-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--accent);
    color: #fff;
    margin-right: 8px;
    vertical-align: middle;
}

/* Collapsible sections */
.brain-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.brain-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.brain-section-header:hover { background: var(--bg-input); }

.brain-section-arrow {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.brain-section-title { font-size: 13px; font-weight: 600; }
.brain-section-h1 { color: var(--accent); font-size: 14px; }
.brain-section-h2 { color: var(--text-primary); }
.brain-section-h3 { color: var(--text-secondary); font-weight: 500; }

.brain-section-body { padding: 0 14px 12px; }

.brain-section-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    background: none;
    border: none;
    padding: 8px 0 0;
}

/* Raw editor */
.brain-editor {
    width: 100%;
    min-height: 400px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-primary);
    resize: vertical;
    box-sizing: border-box;
}

.brain-editor:focus { outline: none; border-color: var(--accent); }

/* Mobile */
@media (max-width: 768px) {
    .brain-hero { flex-direction: column; text-align: center; }
    .brain-hero-stats { justify-content: center; }
    .brain-grid { grid-template-columns: repeat(2, 1fr); }
    .brain-card-grid { grid-template-columns: 1fr; }
    .brain-zone-header { flex-direction: column; gap: 10px; }
    .brain-file-topbar { flex-direction: column; align-items: flex-start; }
}

/* ===== Sofia Module ===== */

.sofia-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }

.sofia-status-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.sofia-test { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: var(--yellow); }
.sofia-live { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--green); }
.sofia-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.sofia-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 4px; }

/* Escalation cards */
.sofia-esc-card { position: relative; }
.sofia-esc-resolved { opacity: 0.6; }
.sofia-esc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 6px; }
.sofia-esc-question { margin-bottom: 10px; }
.sofia-esc-draft { margin-bottom: 12px; }
.sofia-esc-actions { display: flex; flex-direction: column; gap: 8px; }
.sofia-esc-resolved-info { margin-top: 10px; }

/* Message bubbles */
.sofia-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 85%;
    margin-top: 4px;
}

.sofia-msg-in {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.sofia-msg-out {
    background: rgba(79,143,247,0.12);
    border: 1px solid rgba(79,143,247,0.25);
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

/* Thread list */
.sofia-thread-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.sofia-thread-item:last-child { border-bottom: none; }
.sofia-thread-item:hover { background: rgba(79,143,247,0.03); padding: 12px; border-radius: 6px; margin: 0 -12px; }

.sofia-thread-info { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.sofia-thread-name { font-size: 14px; font-weight: 500; }

.sofia-thread-preview { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.sofia-preview-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sofia-thread-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }

/* Chat view */
.sofia-chat-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 600px;
    overflow-y: auto;
    padding: 16px;
}

.sofia-bubble {
    max-width: 75%;
    animation: brainSlideDown 0.2s ease;
}

.sofia-bubble-in { align-self: flex-start; }
.sofia-bubble-out { align-self: flex-end; }

.sofia-bubble-text {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.sofia-bubble-in .sofia-bubble-text {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.sofia-bubble-out .sofia-bubble-text {
    background: rgba(79,143,247,0.15);
    border: 1px solid rgba(79,143,247,0.25);
    border-bottom-right-radius: 4px;
}

.sofia-bubble-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    padding: 0 4px;
}

.sofia-bubble-in .sofia-bubble-time { text-align: left; }
.sofia-bubble-out .sofia-bubble-time { text-align: right; }

/* Draft cards */
.sofia-draft-card { position: relative; }
.sofia-draft-done { opacity: 0.6; }
.sofia-unanswered-card { position: relative; border-left: 3px solid var(--yellow); }
.sofia-time-bucket { margin-bottom: 8px; }
.badge-purple { background: rgba(168,85,247,0.15); color: #a855f7; }
.badge-gray { background: rgba(156,163,175,0.15); color: #9ca3af; }

/* Learning stats bar */
.sofia-learning-bar {
    display: flex;
    gap: 20px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
}

.sofia-learning-stat { text-align: center; }
.sofia-learning-val { display: block; font-size: 20px; font-weight: 700; }
.sofia-learning-key { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

@media (max-width: 768px) {
    .sofia-bubble { max-width: 90%; }
    .sofia-esc-actions { flex-direction: column; }
    .sofia-learning-bar { flex-wrap: wrap; gap: 12px; }
}

/* ==========================================================================
   COMMAND CENTRE — Redesigned Dashboard
   ========================================================================== */

.cc-shell {
    display: flex;
    flex-direction: column;
    gap: 28px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 0;
}

.cc-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* --- Bot Status Strip --- */
.cc-bot-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.cc-bot-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 180px;
    flex: 1;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    cursor: pointer;
}

.cc-bot-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(79, 143, 247, 0.12);
    color: var(--text-primary);
}

.cc-bot-card--loading {
    opacity: 0.5;
    pointer-events: none;
}

.cc-bot-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cc-indicator--green {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: cc-pulse 2s ease-in-out infinite;
}

.cc-indicator--yellow {
    background: var(--yellow);
    box-shadow: 0 0 6px var(--yellow);
    animation: cc-pulse-yellow 2.5s ease-in-out infinite;
}

.cc-indicator--red {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

.cc-indicator--grey {
    background: var(--text-muted);
}

@keyframes cc-pulse {
    0%, 100% { box-shadow: 0 0 4px var(--green); }
    50% { box-shadow: 0 0 14px var(--green), 0 0 24px rgba(52, 211, 153, 0.3); }
}

@keyframes cc-pulse-yellow {
    0%, 100% { box-shadow: 0 0 4px var(--yellow); }
    50% { box-shadow: 0 0 12px var(--yellow), 0 0 20px rgba(251, 191, 36, 0.3); }
}

.cc-bot-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cc-bot-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cc-bot-uptime {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Key Metrics --- */
.cc-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.cc-metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.cc-metric-card--clickable {
    cursor: pointer;
}

.cc-metric-card--clickable:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(79, 143, 247, 0.12);
    color: var(--text-primary);
}

.cc-metric-card--warn {
    border-color: rgba(248, 113, 113, 0.3);
}

.cc-metric-number {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.cc-metric--loading {
    opacity: 0.3;
}

.cc-metric--alert {
    color: var(--red);
}

.cc-metric-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cc-metric-breakdown {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.cc-metric-sub {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
}

/* --- Attention Needed --- */
.cc-attention {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.cc-attention-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, transform 0.15s;
    cursor: pointer;
}

.cc-attention-card:hover {
    transform: translateY(-2px);
    color: var(--text-primary);
}

.cc-attention-card--escalation {
    border-left: 3px solid var(--red);
}
.cc-attention-card--escalation:hover { border-color: var(--red); }

.cc-attention-card--recs {
    border-left: 3px solid var(--yellow);
}
.cc-attention-card--recs:hover { border-color: var(--yellow); }

.cc-attention-card--stale {
    border-left: 3px solid var(--orange);
}
.cc-attention-card--stale:hover { border-color: var(--orange); }

.cc-attention-card--clear {
    border-left: 3px solid var(--green);
    cursor: default;
}

.cc-attention-card--loading {
    opacity: 0.5;
    pointer-events: none;
}

.cc-attention-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.cc-attention-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cc-attention-count {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
}

.cc-attention-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.cc-attention-detail {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

/* --- Activity Timeline --- */
.cc-activity {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
}

.cc-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cc-timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.cc-timeline-item:last-child {
    border-bottom: none;
}

.cc-timeline-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    flex-shrink: 0;
    background: var(--bg-input);
}

.cc-timeline-icon--order { background: rgba(96, 165, 250, 0.15); }
.cc-timeline-icon--system { background: rgba(251, 191, 36, 0.15); }
.cc-timeline-icon--sofia { background: rgba(52, 211, 153, 0.15); }
.cc-timeline-icon--stock { background: rgba(251, 146, 60, 0.15); }
.cc-timeline-icon--session { background: rgba(79, 143, 247, 0.15); }

.cc-timeline-body {
    flex: 1;
    min-width: 0;
}

.cc-timeline-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.cc-timeline-detail {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cc-timeline-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

.cc-activity-footer {
    margin-top: 14px;
    text-align: right;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .cc-bot-strip {
        gap: 8px;
    }
    .cc-bot-card {
        min-width: 150px;
        padding: 10px 14px;
    }
    .cc-metrics {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .cc-metric-number {
        font-size: 2.2rem;
    }
    .cc-attention {
        grid-template-columns: 1fr;
    }
    .cc-attention-detail {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .cc-shell {
        gap: 20px;
    }
    .cc-bot-card {
        min-width: 130px;
        padding: 8px 10px;
    }
    .cc-bot-name {
        font-size: 12px;
    }
    .cc-metric-card {
        padding: 16px 14px;
    }
    .cc-metric-number {
        font-size: 1.8rem;
    }
}

/* ==========================================================================
   BOTS MODULE — Listing + Detail Pages
   ========================================================================== */

/* --- Bot Card Grid --- */
.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.bot-card-link {
    text-decoration: none;
    color: inherit;
}
.bot-card-link:hover { color: inherit; }

.bot-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.bot-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(79, 143, 247, 0.12);
}

.bot-card-active {
    border-color: rgba(52, 211, 153, 0.25);
}

.bot-card-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--green), rgba(52, 211, 153, 0.2));
}

.bot-card-active:hover {
    box-shadow: 0 8px 24px rgba(52, 211, 153, 0.1);
}

.bot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.bot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.bot-card-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bot-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.bot-status-active {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: bot-pulse 2s ease-in-out infinite;
}

.bot-status-stopped {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

.bot-status-unknown {
    background: var(--yellow);
    box-shadow: 0 0 6px var(--yellow);
    animation: bot-pulse-yellow 2.5s ease-in-out infinite;
}

@keyframes bot-pulse {
    0%, 100% { box-shadow: 0 0 4px var(--green); }
    50% { box-shadow: 0 0 14px var(--green), 0 0 24px rgba(52, 211, 153, 0.3); }
}

@keyframes bot-pulse-yellow {
    0%, 100% { box-shadow: 0 0 4px var(--yellow); }
    50% { box-shadow: 0 0 12px var(--yellow), 0 0 20px rgba(251, 191, 36, 0.3); }
}

.bot-status-text {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.bot-card-body {
    margin-bottom: 12px;
}

.bot-card-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.bot-card-type {
    margin-bottom: 8px;
}

.bot-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.bot-card-schedule {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
}

.bot-card-metric {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.bot-metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.bot-metric-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bot-card-extras {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.bot-extra-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(251, 191, 36, 0.12);
    color: var(--yellow);
}

/* --- Bot Detail Page --- */
.bot-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.bot-detail-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.bot-detail-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    flex-shrink: 0;
}

.bot-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bot-detail-name {
    font-size: 22px;
    font-weight: 700;
}

.bot-detail-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bot-status-text-lg {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.bot-detail-desc {
    font-size: 13px;
    color: var(--text-muted);
}

.bot-detail-stat {
    text-align: right;
}

.bot-detail-stat-value {
    display: block;
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.bot-detail-stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Bot Tabs --- */
.bot-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.bot-tabs .tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.bot-tabs .tab:hover {
    color: var(--text-primary);
    background: rgba(79, 143, 247, 0.05);
}

.bot-tabs .tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.bot-tabs .tab-legacy {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 10px 14px;
}
.bot-tabs .tab-legacy:hover {
    color: var(--accent);
}

/* --- Bot Overview Stats Grid --- */
.bot-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.bot-stat-card {
    text-align: center;
    padding: 24px 16px;
}

.bot-stat-number {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.bot-stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bot-stat-breakdown {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.bot-stat-breakdown span {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
}

/* --- Bot Status Bar --- */
.bot-status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 8px 0;
}

.bot-status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.bot-status-key {
    color: var(--text-muted);
}

/* --- Bot Thread List --- */
.bot-thread-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.bot-thread-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.bot-thread-item:last-child { border-bottom: none; }

.bot-thread-name {
    font-size: 14px;
    font-weight: 600;
}

.bot-thread-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.bot-thread-preview {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Bot Conversations Layout --- */
.bot-conversations {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    min-height: 400px;
}

.bot-conversations .bot-thread-list {
    max-height: 600px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0;
}

.bot-thread-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.bot-thread-card:hover { background: var(--bg-input); }
.bot-thread-card.selected { background: rgba(79, 143, 247, 0.1); border-left: 3px solid var(--accent); }
.bot-thread-card:last-child { border-bottom: none; }

.bot-thread-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.bot-thread-meta-line {
    font-size: 12px;
    color: var(--text-muted);
}

.bot-thread-count {
    font-size: 11px;
}

.bot-thread-preview-line {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 1px 0;
}

.preview-sofia { color: var(--green); }
.preview-customer { color: var(--text-secondary); }

.bot-chat-viewer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    max-height: 600px;
    overflow-y: auto;
}

/* --- Bot Escalation Cards --- */
.bot-esc-card {
    border-left: 3px solid var(--border);
}

.bot-esc-pending {
    border-left-color: var(--yellow);
}

.bot-esc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.bot-esc-time {
    font-size: 12px;
    color: var(--text-muted);
}

.bot-esc-reason {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-style: italic;
}

.bot-esc-message {
    font-size: 13px;
    margin-bottom: 6px;
}

.bot-esc-analysis {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.bot-esc-label {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
}

.bot-esc-reply {
    font-size: 13px;
    color: var(--green);
    margin-top: 8px;
}

.bot-esc-form {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: flex-end;
}

.bot-esc-form textarea {
    flex: 1;
}

/* --- Bot Persona Editor --- */
.bot-persona-editor {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    width: 100%;
    resize: vertical;
}

/* --- Bot Approval Items --- */
.bot-approval-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.bot-approval-item:last-child { border-bottom: none; }

.bot-approval-text {
    font-size: 13px;
    flex: 1;
    min-width: 0;
}

.bot-approval-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* --- Bot Learning List --- */
.bot-learning-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.bot-learning-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.bot-learning-item:last-child { border-bottom: none; }

.bot-learning-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bot-learning-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Bot Config Note --- */
.bot-config-note {
    padding: 12px;
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 13px;
}

/* --- Responsive Bots --- */
@media (max-width: 768px) {
    .bot-grid {
        grid-template-columns: 1fr;
    }
    .bot-detail-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .bot-detail-stat {
        text-align: left;
    }
    .bot-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .bot-conversations {
        grid-template-columns: 1fr;
    }
    .bot-conversations .bot-thread-list {
        max-height: 300px;
    }
    .bot-tabs .tab {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .bot-overview-grid {
        grid-template-columns: 1fr;
    }
    .bot-stat-number {
        font-size: 1.8rem;
    }
    .bot-card-name {
        font-size: 16px;
    }
    .bot-metric-value {
        font-size: 22px;
    }
    .bot-esc-form {
        flex-direction: column;
    }
}
