/* BackStage BI Analytics — fintech-grade dashboards */

.bi-page { font-family: 'Inter', system-ui, sans-serif; }

.bi-toolbar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    padding: 16px 20px; background: #fff; border: 1px solid #e8ecf1;
    border-radius: 14px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(26,35,50,0.04);
}

.bi-toolbar .bi-field label {
    display: block; font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: #64748b; margin-bottom: 4px;
}

.bi-toolbar input, .bi-toolbar select {
    padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px;
    font-size: 0.875rem; min-width: 130px; background: #fafbfc;
}

.bi-btn {
    padding: 8px 18px; border-radius: 8px; font-size: 0.875rem; font-weight: 600;
    cursor: pointer; border: none; transition: 0.2s;
}

.bi-btn--primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; }
.bi-btn--ghost { background: transparent; color: #64748b; border: 1px solid #e2e8f0; }

.bi-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.bi-kpi {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 14px;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.bi-kpi-label {
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: #64748b; margin-bottom: 6px;
}

.bi-kpi-value {
    font-size: 1.65rem; font-weight: 700; color: #1a2332;
    font-variant-numeric: tabular-nums; line-height: 1.2;
}

.bi-kpi-value--money { color: #0d9488; }

.bi-kpi-value--warn { color: #ea580c; }
.bi-kpi-value--info { color: #1d4ed8; }
.bi-kpi-value--danger { color: #dc2626; }
.bi-kpi-value--success { color: #059669; }
.bi-kpi-value--purple { color: #7c3aed; }
.bi-kpi-value--amber { color: #d97706; }

.bi-kpi--danger { border-color: #fecaca; }
.bi-kpi--success { border-color: #bbf7d0; }
.bi-kpi--purple { border-color: #e9d5ff; }
.bi-kpi--amber { border-color: #fde68a; }
.bi-kpi--critical { border-color: #fecaca; }

.bi-kpi-hint {
    margin-top: 6px;
    font-size: 0.72rem;
    line-height: 1.35;
    color: #64748b;
    font-weight: 500;
}

.bi-kpi-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.78rem; }

.bi-delta {
    display: inline-flex; padding: 2px 8px; border-radius: 6px; font-weight: 600; font-size: 0.75rem;
}

.bi-delta--up { background: #ecfdf5; color: #059669; }
.bi-delta--down { background: #fef2f2; color: #dc2626; }
.bi-delta--flat { background: #f1f5f9; color: #64748b; }

.bi-charts {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.bi-chart-card {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 14px;
    padding: 20px;
    grid-column: span 6;
}

.bi-chart-card--wide { grid-column: span 8; }
.bi-chart-card--narrow { grid-column: span 4; }
.bi-chart-card--full { grid-column: span 12; }

@media (max-width: 1200px) {
    .bi-chart-card, .bi-chart-card--wide, .bi-chart-card--narrow { grid-column: span 12; }
}

.bi-chart-head { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9; }
.bi-chart-title { font-size: 0.9rem; font-weight: 700; color: #1a2332; }
.bi-chart-sub { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }

.bi-table-wrap { background: #fff; border: 1px solid #e8ecf1; border-radius: 14px; overflow: hidden; margin-bottom: 20px; }
.bi-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.bi-table th {
    padding: 10px 14px; text-align: right; font-size: 0.68rem; font-weight: 600;
    text-transform: uppercase; color: #64748b; background: #f8fafc;
}
.bi-table th:first-child { text-align: left; }
.bi-table td { padding: 11px 14px; text-align: right; border-bottom: 1px solid #f8fafc; font-variant-numeric: tabular-nums; }
.bi-table td:first-child { text-align: left; font-weight: 600; }
.bi-table .bi-total td { background: #f0fdf9; font-weight: 700; }

.org-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid #e8ecf1; }
.org-tab {
    padding: 10px 16px; border: none; background: none; cursor: pointer;
    font-size: 0.85rem; font-weight: 600; color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.org-tab.active { color: #2563eb; border-bottom-color: #2563eb; }

.org-kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.org-col { min-width: 200px; flex: 1; background: #f8fafc; border-radius: 12px; border: 1px solid #e8ecf1; max-height: 420px; display: flex; flex-direction: column; }
.org-col-head { padding: 10px 12px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; border-bottom: 1px solid #e8ecf1; background: #fff; }
.org-col-cards { padding: 8px; overflow-y: auto; flex: 1; }
.org-card { background: #fff; border: 1px solid #e8ecf1; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; font-size: 0.82rem; transition: box-shadow 0.15s, border-color 0.15s; }
.org-card--interactive:hover { border-color: #2563eb; box-shadow: 0 4px 12px rgba(37,99,235,0.12); cursor: pointer; }
.org-card.dragging { opacity: 0.5; }
.org-col.drag-over { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }

.kpi-chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.kpi-chip--money { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.kpi-chip--tempo { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.card-kpi-chips { margin-top: 4px; }

.mail-compose { background: #f8fafc; border: 1px solid #e8ecf1; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.mail-thread { max-height: 280px; overflow-y: auto; }
.mail-item { padding: 12px; border-radius: 10px; margin-bottom: 8px; font-size: 0.84rem; border: 1px solid #e8ecf1; }
.mail-item--out { background: #eff6ff; }
.mail-item--in { background: #f0fdf4; }

.bi-kpi--link:hover { border-color: #2563eb; box-shadow: 0 4px 12px rgba(37,99,235,0.08); }

@media (max-width: 768px) {
    .bi-kpi-row { grid-template-columns: repeat(2, 1fr) !important; }
    .bi-charts { grid-template-columns: 1fr !important; }
    .bi-toolbar { flex-direction: column; align-items: stretch; }
    .bi-toolbar .bi-field input, .bi-toolbar .bi-field select { width: 100%; min-width: 0; }
    .org-kanban { flex-direction: column; }
    .org-col { max-height: none; min-width: 100%; }
}

@media print {
    .no-print, .fi-sidebar, .fi-topbar, .bi-toolbar { display: none !important; }
    .bi-page { padding: 0; }
    .bi-chart-card { break-inside: avoid; page-break-inside: avoid; }
}

.bi-view-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.bi-view-tab {
    padding: 8px 16px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff;
    font-size: 0.85rem; font-weight: 600; color: #334155; cursor: pointer;
}
.bi-view-tab:hover { border-color: #93c5fd; color: #1d4ed8; background: #f8fafc; }
.bi-view-tab.active { background: #dbeafe; border-color: #60a5fa; color: #1e40af; font-weight: 700; }

.bi-perf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.bi-perf-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.bi-perf-card {
    background: #fff; border: 1px solid #e8ecf1; border-radius: 14px; padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(26,35,50,0.04);
}

.bi-perf-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.bi-perf-card__title { font-size: 1rem; font-weight: 700; color: #1a2332; margin: 0; line-height: 1.3; }
.bi-perf-card__badge { font-size: 0.72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #f1f5f9; color: #475569; white-space: nowrap; }

.bi-perf-card__kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.bi-perf-card__kpi-label { display: block; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #94a3b8; margin-bottom: 2px; }
.bi-perf-card__kpi-value { display: block; font-size: 0.95rem; font-weight: 700; color: #1e293b; }
.bi-perf-card__kpi-value--money { color: #0d9488; }

.bi-perf-card__audience { padding: 10px 12px; background: #faf5ff; border-radius: 10px; margin-bottom: 10px; border: 1px solid #e9d5ff; }
.bi-perf-card__audience-row { display: flex; gap: 12px; font-size: 0.82rem; font-weight: 600; margin-top: 4px; }

.bi-perf-card__expenses { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 12px; background: #fff7ed; border-radius: 10px; margin-bottom: 10px; border: 1px solid #fed7aa; }

.bi-perf-card__contracts summary, .bi-perf-card__months summary { cursor: pointer; font-size: 0.82rem; font-weight: 600; color: #2563eb; margin-bottom: 8px; }
.bi-perf-card__contracts ul { margin: 0; padding-left: 0; list-style: none; font-size: 0.8rem; }
.bi-perf-card__contracts li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }

.bi-perf-card__dynamics { margin-top: 10px; }
.bi-perf-card__bars { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.bi-perf-card__bar-row { display: grid; grid-template-columns: 72px 1fr 28px; gap: 8px; align-items: center; font-size: 0.75rem; }
.bi-perf-card__bar-track { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.bi-perf-card__bar-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #60a5fa); border-radius: 4px; }
.bi-perf-card__bar-val { text-align: right; font-weight: 600; color: #475569; }

.bi-table--compact { font-size: 0.78rem; }
.bi-table--compact th, .bi-table--compact td { padding: 6px 10px; }

.bi-limit-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.bi-limit-table th, .bi-limit-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; text-align: left; }
.bi-limit-table input { width: 100%; padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 8px; }
