/* ═══════════════════════════════════════════
   OpenClaw Dashboard — Dark Neon Theme
   Modular, extensible, future-proof
   ═══════════════════════════════════════════ */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --bg-hover: #252d38;
    --bg-input: #0d1117;
    --border: #30363d;
    --border-light: #3d444d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #656d76;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --green-dim: #1a4023;
    --yellow: #d29922;
    --yellow-dim: #3d2e00;
    --red: #f85149;
    --red-dim: #3d1418;
    --purple: #bc8cff;
    --orange: #f0883e;
    --cyan: #39d2c0;
    --sidebar-width: 220px;
    --header-height: 56px;
    --radius: 8px;
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* ─── Scrollbar ─── */
::-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: var(--border-light); }

/* ═══════════ SIDEBAR ═══════════ */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

#sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-header {
    padding: 20px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 28px;
    line-height: 1;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
}

.sidebar-status {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    transition: background var(--transition);
}

.status-dot.connected { background: var(--green); }
.status-dot.connecting { background: var(--yellow); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.nav-menu {
    list-style: none;
    padding: 8px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 2px;
    font-size: 14px;
}

.nav-item:hover { background: var(--bg-hover); }
.nav-item.active {
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent);
}

.nav-icon { font-size: 17px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* ═══════════ MAIN CONTENT ═══════════ */
#main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: margin-left var(--transition);
}

#main-content.expanded { margin-left: 0; }

/* ─── Header ─── */
#header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: none;
    padding: 4px;
}

#page-title {
    font-size: 16px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.badge.green { border-color: var(--green); color: var(--green); }
.badge.red { border-color: var(--red); color: var(--red); }
.badge.yellow { border-color: var(--yellow); color: var(--yellow); }

.clock {
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    font-size: 13px;
    color: var(--text-muted);
}

/* ═══════════ PAGES ═══════════ */
.page {
    display: none;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.page.active { display: block; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    margin-top: 4px;
}

.section-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ═══════════ KPI CARDS ═══════════ */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: border-color var(--transition);
}

.kpi-card:hover { border-color: var(--accent); }

.kpi-card.large { padding: 24px; }

.kpi-icon { font-size: 24px; }

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    color: var(--accent);
}

.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ═══════════ AGENT GRID ═══════════ */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.agent-grid.full {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    transition: all var(--transition);
    cursor: default;
    position: relative;
    overflow: hidden;
}

.agent-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--green);
    transition: background var(--transition);
}

.agent-card.error::before { background: var(--red); }
.agent-card.warning::before { background: var(--yellow); }

.agent-card:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.agent-name {
    font-size: 14px;
    font-weight: 600;
}

.agent-role {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
}

.agent-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.agent-stat {
    display: flex;
    justify-content: space-between;
}

.agent-stat .val {
    font-family: monospace;
    color: var(--text-primary);
}

/* ═══════════ PIPELINE ═══════════ */
.pipeline-flow {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 12px 0;
    margin-bottom: 20px;
}

.pipeline-flow.large {
    gap: 8px;
    padding: 20px 0;
}

.pipeline-stage {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    min-width: 100px;
    text-align: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.pipeline-flow.large .pipeline-stage {
    padding: 16px 20px;
    min-width: 140px;
}

.pipeline-stage:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.pipeline-stage.active {
    border-color: var(--green);
    box-shadow: 0 0 12px rgba(63, 185, 80, 0.15);
}

.pipeline-stage .stage-icon { font-size: 20px; }
.pipeline-flow.large .pipeline-stage .stage-icon { font-size: 28px; }

.pipeline-stage .stage-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.pipeline-flow.large .pipeline-stage .stage-name { font-size: 13px; }

.pipeline-stage .stage-tasks {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    font-family: monospace;
}

.pipeline-arrow {
    color: var(--border-light);
    font-size: 16px;
    flex-shrink: 0;
}

/* ═══════════ LOG VIEWER ═══════════ */
.log-container {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 12px;
    overflow-y: auto;
    padding: 8px;
}

.log-container.mini { height: 200px; }
.log-container.full { height: calc(100vh - 180px); }

.log-line {
    padding: 2px 6px;
    border-radius: 3px;
    display: flex;
    gap: 8px;
    white-space: nowrap;
    transition: background var(--transition);
}

.log-line:hover { background: var(--bg-hover); }

.log-time { color: var(--text-muted); min-width: 65px; }
.log-level { min-width: 55px; font-weight: 600; }
.log-level.INFO { color: var(--accent); }
.log-level.WARNING { color: var(--yellow); }
.log-level.ERROR { color: var(--red); }
.log-level.DEBUG { color: var(--text-muted); }
.log-module { color: var(--cyan); min-width: 100px; }
.log-msg { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; }

.log-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ═══════════ ACTIONS ═══════════ */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.action-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.action-card.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.action-card:active { transform: translateY(0); }

.action-icon { font-size: 36px; margin-bottom: 10px; }

.action-card h4 { font-size: 14px; margin-bottom: 4px; }

.action-card p {
    font-size: 12px;
    color: var(--text-muted);
}

.agent-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.agent-action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.agent-action-card h4 {
    font-size: 13px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.agent-action-card .btn-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ═══════════ ANALYTICS ═══════════ */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.stat-card h5 {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.stat-card .stat-values {
    display: grid;
    gap: 4px;
    font-size: 13px;
}

.stat-card .stat-row {
    display: flex;
    justify-content: space-between;
}

.stat-card .stat-row .val {
    font-family: monospace;
    color: var(--accent);
}

/* ═══════════ SETTINGS ═══════════ */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.settings-card-wide { grid-column: 1 / -1; }

.settings-card h4 { font-size: 14px; margin-bottom: 12px; }

.settings-table-wrap { overflow-x: auto; }
.settings-table-wrap .mini-table { width: 100%; }
.settings-table-wrap .mini-table th,
.settings-table-wrap .mini-table td { padding: 6px 10px; font-size: 12px; }

.settings-form-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.input-med {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    width: 160px;
}

.cb-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn-xs {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all .2s;
}
.btn-xs:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { color: var(--red) !important; }
.btn-danger:hover { border-color: var(--red) !important; background: rgba(255,85,85,.1) !important; }

.btn-sm {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Add form block ─── */
.add-form-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.add-form-block h5 {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}
.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-field label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── Login status panel ─── */
.login-panel {
    margin-top: 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: rgba(88, 166, 255, 0.04);
    overflow: hidden;
}
.login-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(88, 166, 255, 0.08);
    border-bottom: 1px solid rgba(88, 166, 255, 0.15);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}
.login-panel-body {
    padding: 10px 12px;
    max-height: 300px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.6;
}
.login-log-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.login-log-entry:last-child { border-bottom: none; }
.login-log-time {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
    min-width: 50px;
}
.login-log-msg { flex: 1; }
.login-log-ok { color: var(--green); }
.login-log-err { color: var(--red); }
.login-log-warn { color: var(--yellow); }
.login-log-info { color: var(--text-secondary); }

/* Account status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.status-logged-in {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}
.status-error {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}
.status-challenge {
    background: var(--yellow-dim);
    color: var(--yellow);
    border: 1px solid rgba(210, 153, 34, 0.3);
}
.status-unknown {
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.status-logging-in {
    background: rgba(88, 166, 255, 0.08);
    color: var(--accent);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

/* Login button states */
.btn-login {
    background: rgba(88, 166, 255, 0.08);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.btn-login:hover { background: rgba(88, 166, 255, 0.18); }
.btn-login:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-login.logging-in {
    animation: pulse-accent 1.2s infinite;
}
@keyframes pulse-accent {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Error detail row */
.error-detail {
    font-size: 11px;
    color: var(--red);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: help;
}

/* Challenge code form */
.challenge-form {
    margin-top: 12px;
    padding: 12px;
    background: rgba(210, 153, 34, 0.06);
    border: 1px solid rgba(210, 153, 34, 0.25);
    border-radius: 6px;
}
.challenge-prompt {
    font-size: 13px;
    color: var(--yellow);
    margin-bottom: 8px;
    font-weight: 500;
}
.challenge-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.challenge-code-input {
    background: var(--bg-input);
    border: 2px solid var(--yellow);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 18px;
    font-family: monospace;
    letter-spacing: 4px;
    width: 180px;
    text-align: center;
}
.challenge-code-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}
.challenge-code-input::placeholder {
    letter-spacing: 2px;
    opacity: 0.4;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-row label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ═══════════ FORMS ═══════════ */
.input-small {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    width: 100px;
}

.input-full {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
}

select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
}

input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

input[type="range"] {
    accent-color: var(--accent);
    width: 120px;
}

.btn-small {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-small:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.btn-small.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-small.danger {
    border-color: var(--red);
    color: var(--red);
}

.btn-small.danger:hover {
    background: var(--red-dim);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ═══════════ TOAST NOTIFICATIONS ═══════════ */
#toasts {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    min-width: 280px;
    max-width: 400px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--yellow); }

.toast-icon { font-size: 18px; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ═══════════ PIPELINE STATS ═══════════ */
.pipeline-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

/* ═══════════ ACTIVITY FEED ═══════════ */
.activity-feed { display: flex; flex-direction: column; gap: 4px; }
.activity-feed.mini { max-height: 300px; overflow-y: auto; }
.activity-feed.full { max-height: calc(100vh - 260px); overflow-y: auto; }

.activity-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius);
    background: var(--bg-card); border: 1px solid var(--border);
    border-left: 3px solid var(--accent); transition: all var(--transition);
}
.activity-item:hover { background: var(--bg-hover); border-color: var(--border-light); }
.activity-icon { font-size: 18px; flex-shrink: 0; }
.activity-content { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.activity-title { font-size: 13px; color: var(--text-primary); }
.activity-user { font-size: 12px; color: var(--cyan); font-weight: 600; }
.activity-agent { font-size: 11px; color: var(--text-muted); background: var(--bg-primary); padding: 1px 6px; border-radius: 4px; }
.activity-time { font-size: 11px; color: var(--text-muted); font-family: monospace; flex-shrink: 0; white-space: nowrap; }
.activity-empty { color: var(--text-muted); padding: 20px; text-align: center; font-size: 13px; }
.activity-stats-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.activity-stat-badge {
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 16px; font-size: 12px;
    display: flex; align-items: center; gap: 6px; cursor: pointer;
    transition: all var(--transition);
}
.activity-stat-badge:hover { border-color: var(--accent); background: var(--bg-hover); }
.activity-stat-badge .val { font-family: monospace; color: var(--accent); font-weight: 600; }

/* ═══════════ LEADS ═══════════ */
.leads-distribution { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.lead-dist-badge {
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 6px 14px; border-radius: 16px; font-size: 12px;
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    transition: all var(--transition);
}
.lead-dist-badge:hover { border-color: var(--accent); background: var(--bg-hover); }
.lead-dist-badge .val { font-family: monospace; color: var(--accent); font-weight: 700; }
.lead-dist-badge.total { border-color: var(--cyan); }
.lead-dist-badge.total .val { color: var(--cyan); }

.leads-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.leads-table {
    width: 100%; border-collapse: collapse;
    font-size: 13px; background: var(--bg-card);
}
.leads-table thead { background: var(--bg-secondary); }
.leads-table th {
    padding: 10px 12px; text-align: left; font-weight: 600;
    color: var(--text-secondary); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.leads-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.lead-row { cursor: pointer; transition: background var(--transition); }
.lead-row:hover { background: var(--bg-hover); }
.lead-profile { display: flex; flex-direction: column; gap: 2px; }
.lead-profile strong { color: var(--accent); font-size: 13px; }
.lead-name { font-size: 11px; color: var(--text-muted); }
.lead-niche { font-size: 12px; color: var(--purple); background: rgba(188,140,255,0.1); padding: 2px 8px; border-radius: 4px; }
.lead-status-badge { font-size: 11px; padding: 3px 8px; border-radius: 4px; white-space: nowrap; }
.lead-status-badge.status-new { background: rgba(88,166,255,0.15); color: var(--accent); }
.lead-status-badge.status-contacted { background: rgba(63,185,80,0.15); color: var(--green); }
.lead-status-badge.status-replied { background: rgba(210,153,34,0.15); color: var(--yellow); }
.lead-status-badge.status-interested { background: rgba(240,136,62,0.15); color: var(--orange); }
.lead-status-badge.status-negotiating { background: rgba(57,210,192,0.15); color: var(--cyan); }
.lead-status-badge.status-closed_won { background: rgba(63,185,80,0.25); color: var(--green); font-weight: 700; }
.lead-status-badge.status-closed_lost { background: rgba(248,81,73,0.15); color: var(--red); }
.lead-status-badge.status-not_interested { background: rgba(248,81,73,0.1); color: var(--text-muted); }
.lead-score { font-family: monospace; font-weight: 700; color: var(--accent); }
.lead-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* Lead Detail Panel */
.lead-detail {
    display: none; position: fixed; top: 0; right: 0;
    width: 580px; max-width: 90vw; height: 100vh;
    background: var(--bg-secondary); border-left: 1px solid var(--border);
    z-index: 200; overflow-y: auto;
    box-shadow: -8px 0 30px rgba(0,0,0,0.5);
    animation: slideInRight 0.25s ease;
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.lead-detail-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    background: var(--bg-card); position: sticky; top: 0; z-index: 1;
}
.lead-detail-header h3 { font-size: 15px; }
.lead-detail-header .close-btn {
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; cursor: pointer; padding: 4px;
}
.lead-detail-header .close-btn:hover { color: var(--red); }
.lead-detail-body { padding: 20px; }
.lead-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.lead-info-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px;
}
.lead-info-card.full-width { grid-column: 1 / -1; }
.lead-info-card h5 { font-size: 12px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; }
.info-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--text-secondary); }
.info-row span:last-child { color: var(--text-primary); font-family: monospace; }
.info-row a { color: var(--accent); text-decoration: none; }
.info-row a:hover { text-decoration: underline; }

.memory-summary { margin-top: 10px; padding: 10px; background: var(--bg-primary); border-radius: 6px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.memory-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fact-tag { background: rgba(88,166,255,0.12); color: var(--accent); padding: 3px 10px; border-radius: 12px; font-size: 11px; }

.lead-messages-section { margin-top: 20px; }
.lead-messages-section h5 { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.lead-messages { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; }
.lead-bio { margin-top: 16px; }
.lead-bio h5 { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.lead-bio p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ═══════════ CHAT MESSAGES ═══════════ */
.chat-msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.chat-msg.outgoing { background: rgba(88,166,255,0.15); border: 1px solid rgba(88,166,255,0.25); align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg.incoming { background: var(--bg-card); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg-text { color: var(--text-primary); word-break: break-word; }
.chat-msg-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 6px; }

/* ═══════════ DIALOGS ═══════════ */
.dialogs-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 150px); }
.dialog-list {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow-y: auto; padding: 8px;
}
.dialog-item {
    padding: 12px; border-radius: 6px; cursor: pointer;
    border: 1px solid transparent; margin-bottom: 4px;
    transition: all var(--transition);
}
.dialog-item:hover { background: var(--bg-hover); }
.dialog-item.active { background: var(--bg-hover); border-color: var(--accent); }
.dialog-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.dialog-item-header strong { font-size: 13px; color: var(--accent); }
.dialog-intent { font-size: 11px; color: var(--text-muted); }
.dialog-item-summary { font-size: 12px; color: var(--text-secondary); line-height: 1.4; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dialog-item-meta { display: flex; gap: 8px; font-size: 11px; color: var(--text-muted); }
.dialog-empty { color: var(--text-muted); padding: 30px; text-align: center; font-size: 13px; }

.dialog-chat {
    display: flex; flex-direction: column;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.dialog-chat-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    background: var(--bg-secondary); display: flex; align-items: center; gap: 10px;
}
.dialog-chat-header strong { color: var(--accent); }
.dialog-chat-header span { font-size: 12px; color: var(--text-muted); }
.dialog-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.dialog-memory {
    border-top: 1px solid var(--border); padding: 12px 16px;
    background: var(--bg-secondary);
}
.dialog-memory h5 { font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; }

.memory-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.memory-meta span { background: var(--bg-primary); padding: 3px 8px; border-radius: 4px; }
.memory-text { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 768px) {
    .hamburger { display: block; }
    #sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
    #sidebar.open { transform: translateX(0); }
    #main-content { margin-left: 0; }
    .kpi-row { grid-template-columns: 1fr 1fr; }
    .agent-grid { grid-template-columns: 1fr; }
    .actions-grid { grid-template-columns: 1fr 1fr; }
    .dialogs-layout { grid-template-columns: 1fr; }
    .lead-detail { width: 100vw; }
    .lead-info-grid { grid-template-columns: 1fr; }
}

/* ═══════════ COMMAND CENTER CHAT ═══════════ */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.qa-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.qa-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(88, 166, 255, 0.06);
}

.cmd-chat {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: calc(100vh - 210px);
    overflow: hidden;
}

.cmd-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cmd-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeInMsg .3s ease;
}
.cmd-msg.bot { align-self: flex-start; }
.cmd-msg.user { align-self: flex-end; flex-direction: row-reverse; }

@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.cmd-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.cmd-msg.user .cmd-msg-avatar { background: rgba(88, 166, 255, 0.15); }

.cmd-msg-body {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 60px;
}
.cmd-msg.user .cmd-msg-body {
    background: rgba(88, 166, 255, 0.08);
    border-color: rgba(88, 166, 255, 0.2);
}

.cmd-msg-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}
.cmd-msg.user .cmd-msg-name { color: var(--text-muted); text-align: right; }

.cmd-msg-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
}
.cmd-msg-text code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--cyan);
}
.cmd-msg-text pre {
    background: var(--bg-primary);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.5;
    border: 1px solid var(--border);
}
.cmd-msg-text .cmd-success { color: var(--green); }
.cmd-msg-text .cmd-error { color: var(--red); }
.cmd-msg-text .cmd-warn { color: var(--yellow); }
.cmd-msg-text .cmd-info { color: var(--text-secondary); }
.cmd-msg-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
}
.cmd-msg-text table th,
.cmd-msg-text table td {
    padding: 4px 10px;
    border: 1px solid var(--border);
    text-align: left;
}
.cmd-msg-text table th {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 600;
}

/* Typing indicator */
.cmd-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.cmd-typing span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.2s ease infinite;
}
.cmd-typing span:nth-child(2) { animation-delay: .2s; }
.cmd-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
    0%, 100% { opacity: .3; transform: scale(.8); }
    50% { opacity: 1; transform: scale(1); }
}

.cmd-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.cmd-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}
.cmd-input:focus { border-color: var(--accent); }
.cmd-input::placeholder { color: var(--text-muted); }

.cmd-send-btn {
    padding: 10px 20px;
    font-size: 13px;
    border-radius: 8px;
    white-space: nowrap;
}
