/* ==========================================================================
   BeDesk AI Dashboard
   Matches BeDesk-Lite design language: Outfit font, emerald (#059669) accent,
   slate neutrals, soft cards. Scoped under .bedesk-ai-wrap to avoid bleed.
   ========================================================================== */

.bedesk-ai-wrap {
    --bai-primary: #059669;
    --bai-primary-d: #047857;
    --bai-ink: #1e293b;
    --bai-muted: #64748b;
    --bai-faint: #94a3b8;
    --bai-line: #e5e9ed;
    --bai-bg: #f8fafc;
    --bai-green: #059669;
    --bai-amber: #f59e0b;
    --bai-red: #dc2626;
    --bai-indigo: #4f46e5;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--bai-ink);
    max-width: 1280px;
    margin: 0 auto;
}

.bedesk-ai-wrap * { box-sizing: border-box; }
.bedesk-ai-wrap .hidden { display: none !important; }

/* Toolbar */
.bai-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.bai-title { font-size: 22px; font-weight: 700; margin: 0; }
.bai-updated { font-size: 12px; color: var(--bai-faint); margin-left: 10px; }
.bai-toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bai-custom { display: inline-flex; gap: 6px; }
.bai-select {
    border: 1px solid var(--bai-line); border-radius: 8px; padding: 7px 10px;
    font-size: 13px; font-family: inherit; background: #fff; color: var(--bai-ink);
}
.bai-btn, .bai-refresh {
    background: var(--bai-primary); color: #fff; border: none; border-radius: 8px;
    padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: background .15s;
}
.bai-btn:hover { background: var(--bai-primary-d); }

.bai-notice {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 20px;
}

.bai-section-label {
    font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--bai-muted); margin: 28px 0 12px;
}
.bai-badge-ai {
    display: inline-block; background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px;
    border-radius: 6px; vertical-align: middle; letter-spacing: .03em;
}

/* KPI cards */
.bai-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}
.bai-skeleton-cards { color: var(--bai-faint); padding: 20px; }
.bai-card {
    background: #fff; border: 1px solid var(--bai-line); border-radius: 12px;
    padding: 18px; position: relative; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.bai-card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--bai-faint);
}
.bai-card.rag-green::before  { background: var(--bai-green); }
.bai-card.rag-amber::before  { background: var(--bai-amber); }
.bai-card.rag-red::before    { background: var(--bai-red); }
.bai-card.rag-neutral::before{ background: #cbd5e1; }
.bai-card-label { font-size: 12.5px; color: var(--bai-muted); font-weight: 600; margin-bottom: 6px; }
.bai-card-value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.bai-card-target { font-size: 11.5px; color: var(--bai-faint); margin-top: 4px; }
.bai-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:5px; }
.bai-dot.rag-green{background:var(--bai-green);} .bai-dot.rag-amber{background:var(--bai-amber);}
.bai-dot.rag-red{background:var(--bai-red);} .bai-dot.rag-neutral{background:#cbd5e1;}

/* Panels & grid */
.bai-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.bai-panel {
    background: #fff; border: 1px solid var(--bai-line); border-radius: 12px;
    padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.bai-panel-title {
    font-size: 15px; font-weight: 700; margin: 0 0 16px;
    display: flex; align-items: center; gap: 8px;
}
.bai-hint { font-size: 11px; font-weight: 500; color: var(--bai-faint); margin-left: auto; }
.bai-copy {
    margin-left: auto; background: none; border: 1px solid var(--bai-line);
    border-radius: 6px; cursor: pointer; padding: 2px 8px; color: var(--bai-muted);
}

/* Tables */
.bai-table-wrap { overflow-x: auto; }
.bai-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bai-table th {
    text-align: left; padding: 10px 8px; color: var(--bai-muted); font-weight: 600;
    border-bottom: 2px solid var(--bai-line); white-space: nowrap;
}
.bai-table td { padding: 10px 8px; border-bottom: 1px solid #f1f5f9; }
.bai-table tr:last-child td { border-bottom: none; }
.bai-delta-up { color: var(--bai-red); font-weight: 600; }
.bai-delta-down { color: var(--bai-green); font-weight: 600; }
.bai-pill {
    display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.bai-pill.green { background:#ecfdf5; color:#047857; }
.bai-pill.amber { background:#fffbeb; color:#b45309; }
.bai-pill.red   { background:#fef2f2; color:#b91c1c; }

/* Health panel */
.bai-health { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bai-health-item {
    background: var(--bai-bg); border-radius: 10px; padding: 14px;
}
.bai-health-item .n { font-size: 24px; font-weight: 700; }
.bai-health-item .l { font-size: 12px; color: var(--bai-muted); }
.bai-health-oldest { grid-column: 1 / -1; }

/* AI bodies */
.bai-ai-body { font-size: 14px; line-height: 1.55; }
.bai-thinking { color: var(--bai-indigo); font-style: italic; display:flex; align-items:center; gap:8px; }
.bai-thinking::before {
    content: ""; width: 14px; height: 14px; border: 2px solid #c7d2fe;
    border-top-color: var(--bai-indigo); border-radius: 50%;
    animation: bai-spin .7s linear infinite;
}
@keyframes bai-spin { to { transform: rotate(360deg); } }
.bai-ai-error { color: var(--bai-red); font-size: 13px; }
.bai-ai-headline { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.bai-ai-list { margin: 8px 0 0; padding-left: 18px; }
.bai-ai-list li { margin-bottom: 5px; }
.bai-kv { margin: 6px 0; }
.bai-kv b { color: var(--bai-ink); }

/* Deflection big stat */
.bai-deflect-stat { font-size: 40px; font-weight: 800; color: var(--bai-indigo); }
.bai-deflect-sub { font-size: 13px; color: var(--bai-muted); }

/* Recommendations */
.bai-rec { border: 1px solid var(--bai-line); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.bai-rec-head { display: flex; align-items: center; gap: 8px; }
.bai-rec-title { font-weight: 700; font-size: 14px; }
.bai-rec-type {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    background: #eef2ff; color: #4338ca; padding: 2px 7px; border-radius: 6px;
}
.bai-rec-impact { margin-left: auto; font-size: 11px; }
.bai-rec-detail { font-size: 13px; color: var(--bai-muted); margin: 8px 0; }
.bai-rec-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bai-rec-actions button {
    border: 1px solid var(--bai-line); background: #fff; border-radius: 7px;
    padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.bai-rec-actions button.active { background: var(--bai-primary); color: #fff; border-color: var(--bai-primary); }
.bai-rec.status-done { opacity: .55; }
.bai-rec.status-dismissed { opacity: .4; }

.bai-foot { text-align: center; color: var(--bai-faint); font-size: 12px; margin: 30px 0 10px; }

/* Responsive */
@media (max-width: 860px) {
    .bai-grid-2 { grid-template-columns: 1fr; }
    .bai-health { grid-template-columns: 1fr; }
}
