.crm-insight {
    --crm-ink: #182033;
    --crm-muted: #667085;
    --crm-line: #e4e9f2;
    --crm-blue: #3157d5;
    --crm-blue-soft: #eef3ff;
    --crm-danger: #c43f4d;
    --crm-warning: #a86608;
    color: var(--crm-ink);
    display: grid;
    gap: 18px;
    min-width: 0;
}

.crm-insight *,
.crm-insight *::before,
.crm-insight *::after {
    box-sizing: border-box;
}

.crm-insight-hero {
    align-items: flex-start;
    background: linear-gradient(135deg, #ffffff 0%, #f5f7ff 72%, #edf4ff 100%);
    border: 1px solid #dce4f4;
    border-radius: 20px;
    box-shadow: 0 18px 42px rgba(36, 57, 107, .08);
    display: flex;
    justify-content: space-between;
    min-height: 148px;
    padding: 28px 30px;
}

.crm-insight-eyebrow {
    color: #4167db;
    display: block;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .14em;
    margin-bottom: 8px;
}

.crm-insight-hero h2 {
    font-size: clamp(24px, 2.4vw, 34px);
    letter-spacing: -.025em;
    line-height: 1.2;
    margin: 0;
}

.crm-insight-hero p {
    color: #4d5b78;
    font-size: 15px;
    line-height: 1.7;
    margin: 10px 0 4px;
    max-width: 760px;
}

.crm-insight-hero small {
    color: #7a869e;
    display: block;
    font-size: 12px;
    line-height: 1.6;
}

.crm-insight-hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.crm-insight-hero-badges span {
    background: rgba(255, 255, 255, .9);
    border: 1px solid #d6dff5;
    border-radius: 999px;
    color: #43527a;
    font-size: 12px;
    font-weight: 650;
    padding: 7px 11px;
    white-space: nowrap;
}

.crm-insight-kpis {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.crm-insight-kpis article {
    background: #fff;
    border: 1px solid var(--crm-line);
    border-radius: 16px;
    display: grid;
    gap: 6px;
    min-height: 116px;
    padding: 20px;
}

.crm-insight-kpis article > span {
    color: #667085;
    font-size: 13px;
    font-weight: 650;
}

.crm-insight-kpis article > strong {
    font-size: clamp(24px, 2vw, 32px);
    letter-spacing: -.03em;
}

.crm-insight-kpis article > small {
    color: #8490a5;
    font-size: 12px;
    line-height: 1.45;
}

.crm-insight-toolbar {
    align-items: end;
    background: #fff;
    border: 1px solid var(--crm-line);
    border-radius: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
}

.crm-insight-toolbar label {
    display: grid;
    flex: 1 1 210px;
    gap: 6px;
    min-width: 180px;
}

.crm-insight-toolbar label > span {
    color: #536078;
    font-size: 12px;
    font-weight: 650;
}

.crm-insight-toolbar input,
.crm-insight-toolbar select {
    appearance: none;
    background: #fff;
    border: 1px solid #cfd7e6;
    border-radius: 10px;
    color: var(--crm-ink);
    font: inherit;
    height: 42px;
    min-width: 0;
    padding: 0 12px;
    width: 100%;
}

.crm-insight-toolbar input:focus,
.crm-insight-toolbar select:focus,
.crm-insight button:focus-visible {
    outline: 3px solid rgba(49, 87, 213, .2);
    outline-offset: 2px;
}

.crm-insight-btn,
.crm-insight button[data-crm-insight-open],
.crm-table-link {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
}

.crm-insight-btn.primary,
.crm-insight button[data-crm-insight-open] {
    background: var(--crm-blue);
    color: #fff;
}

.crm-insight-btn.secondary,
.crm-table-link {
    background: #fff;
    border-color: #cfd7e6;
    color: #34446a;
}

.crm-insight-btn.ghost {
    background: #f7f8fb;
    border-color: #e3e7ef;
    color: #59657c;
}

.crm-insight-btn:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.crm-board {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(6, minmax(250px, 1fr));
    overflow-x: auto;
    padding: 2px 2px 12px;
    scroll-snap-type: x proximity;
}

.crm-board-column {
    background: #f6f8fc;
    border: 1px solid #e1e6ef;
    border-radius: 16px;
    min-height: 360px;
    padding: 12px;
    scroll-snap-align: start;
}

.crm-board-column > header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    padding: 4px 3px 12px;
}

.crm-board-column > header div {
    align-items: center;
    display: flex;
    gap: 7px;
}

.crm-board-column > header span {
    align-items: center;
    background: #e7ebf3;
    border-radius: 99px;
    color: #58657a;
    display: inline-flex;
    font-size: 11px;
    height: 21px;
    justify-content: center;
    min-width: 21px;
}

.crm-board-column > header small {
    color: #667085;
    font-size: 11px;
}

.crm-opportunity-card {
    background: #fff;
    border: 1px solid #e0e5ed;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(31, 43, 74, .04);
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
    padding: 13px;
}

.crm-opportunity-card > div:first-child,
.crm-health-card > header > div,
.crm-renewal-main {
    display: grid;
    gap: 4px;
}

.crm-opportunity-card strong,
.crm-health-card strong,
.crm-renewal-main strong {
    line-height: 1.4;
}

.crm-opportunity-card span,
.crm-health-card header span,
.crm-renewal-main span {
    color: #758097;
    font-size: 12px;
}

.crm-opportunity-card dl {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
    margin: 0;
}

.crm-opportunity-card dl div {
    background: #f7f8fb;
    border-radius: 8px;
    display: grid;
    gap: 3px;
    padding: 8px;
}

.crm-opportunity-card dt {
    color: #7a8599;
    font-size: 10px;
}

.crm-opportunity-card dd {
    font-size: 12px;
    font-weight: 700;
    margin: 0;
}

.crm-opportunity-card p {
    color: #657087;
    font-size: 11px;
    line-height: 1.5;
    margin: 0;
}

.crm-opportunity-card p.warning { color: var(--crm-warning); }
.crm-opportunity-card p.danger { color: var(--crm-danger); font-weight: 650; }

.crm-opportunity-card footer,
.crm-health-card footer {
    align-items: center;
    border-top: 1px solid #edf0f5;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    padding-top: 10px;
}

.crm-opportunity-card footer button,
.crm-health-card footer button {
    min-height: 32px;
    padding: 0 10px;
}

.crm-insight-column-empty,
.crm-board-more {
    color: #8893a7;
    font-size: 12px;
    line-height: 1.6;
    padding: 18px 8px;
    text-align: center;
}

.crm-insight-table-wrap {
    background: #fff;
    border: 1px solid var(--crm-line);
    border-radius: 16px;
    overflow: auto;
}

.crm-insight-table {
    border-collapse: collapse;
    min-width: 1000px;
    width: 100%;
}

.crm-insight-table th,
.crm-insight-table td {
    border-bottom: 1px solid #e8ecf2;
    padding: 14px 13px;
    text-align: left;
    vertical-align: top;
}

.crm-insight-table th {
    background: #f8f9fc;
    color: #657087;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.crm-insight-table td {
    color: #38445b;
    font-size: 13px;
}

.crm-insight-table td strong,
.crm-insight-table td small {
    display: block;
}

.crm-insight-table td small {
    color: #8490a5;
    font-size: 11px;
    line-height: 1.45;
    margin-top: 4px;
}

.crm-insight-table tr:last-child td { border-bottom: 0; }

.crm-priority {
    border-radius: 999px;
    display: inline-block;
    font-size: 11px;
    font-weight: 750;
    padding: 5px 8px;
    white-space: nowrap;
}

.crm-priority.p0 { background: #fff0f1; color: #b83242; }
.crm-priority.p1 { background: #fff6e5; color: #93600c; }
.crm-priority.p2 { background: #edf3ff; color: #3157b7; }

.crm-health-rule {
    align-items: center;
    background: #f8faff;
    border: 1px solid #dce5f7;
    border-radius: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 13px 15px;
}

.crm-health-rule strong { color: #314261; font-size: 13px; }
.crm-health-rule span { border-left: 1px solid #d6deed; color: #657087; font-size: 12px; padding-left: 10px; }

.crm-health-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-health-card {
    background: #fff;
    border: 1px solid var(--crm-line);
    border-left: 4px solid #5c76c8;
    border-radius: 14px;
    display: grid;
    gap: 14px;
    padding: 18px;
}

.crm-health-card.risk { border-left-color: #c94b59; }
.crm-health-card.watch { border-left-color: #d79429; }
.crm-health-card.stable { border-left-color: #2f9670; }
.crm-health-card.unknown { border-left-color: #8b95a7; }

.crm-health-card > header {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
}

.crm-health-card > header em {
    background: #f1f3f8;
    border-radius: 999px;
    color: #4f5c73;
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
    padding: 6px 9px;
}

.crm-health-card.risk > header em { background: #fff0f1; color: #b83242; }
.crm-health-card.watch > header em { background: #fff6e5; color: #94620e; }
.crm-health-card.stable > header em { background: #eaf8f2; color: #28775c; }

.crm-health-evidence {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.crm-health-evidence span {
    background: #f7f8fb;
    border-radius: 8px;
    color: #707b90;
    display: grid;
    font-size: 10px;
    gap: 3px;
    padding: 8px;
    text-align: center;
}

.crm-health-evidence b { color: #26324a; font-size: 16px; }

.crm-health-findings > div {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.crm-health-findings > div b {
    flex-basis: 100%;
    font-size: 12px;
}

.crm-health-findings > div span {
    background: #fff3f3;
    border-radius: 6px;
    color: #9d3e49;
    font-size: 11px;
    padding: 5px 7px;
}

.crm-health-findings > div.positive span { background: #eef8f4; color: #2b765e; }
.crm-health-findings p { color: #7d889c; font-size: 11px; margin: 10px 0 0; }

.crm-renewal-list {
    background: #fff;
    border: 1px solid var(--crm-line);
    border-radius: 16px;
    overflow: hidden;
}

.crm-renewal-list > article {
    align-items: center;
    border-bottom: 1px solid #e8ecf2;
    display: grid;
    gap: 16px;
    grid-template-columns: 155px minmax(0, 1fr) auto;
    padding: 17px 18px;
}

.crm-renewal-list > article:last-child { border-bottom: 0; }

.crm-renewal-date {
    border-left: 3px solid #7888a8;
    display: grid;
    gap: 4px;
    padding-left: 11px;
}

.crm-renewal-date.overdue { border-color: #c94b59; }
.crm-renewal-date.urgent { border-color: #d77c27; }
.crm-renewal-date.watch { border-color: #d3a22a; }
.crm-renewal-date span { color: #758097; font-size: 11px; }
.crm-renewal-main p { color: #69758b; font-size: 12px; margin: 4px 0 0; }
.crm-renewal-actions { align-items: flex-end; display: grid; gap: 7px; justify-items: end; }
.crm-renewal-actions > span { color: #6e7990; font-size: 11px; font-weight: 650; }

.crm-forecast {
    background: #fff;
    border: 1px solid var(--crm-line);
    border-radius: 16px;
    padding: 22px;
}

.crm-forecast-legend {
    display: flex;
    gap: 18px;
    justify-content: flex-end;
}

.crm-forecast-legend span {
    align-items: center;
    color: #667085;
    display: flex;
    font-size: 11px;
    gap: 6px;
}

.crm-forecast-legend i {
    border-radius: 3px;
    height: 10px;
    width: 10px;
}

.crm-forecast-legend i.pipeline,
.crm-forecast-bars i.pipeline { background: #cdd8fb; }
.crm-forecast-legend i.weighted,
.crm-forecast-bars i.weighted { background: #4267db; }

.crm-forecast-chart {
    align-items: stretch;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    min-height: 320px;
    overflow-x: auto;
    padding-top: 18px;
}

.crm-forecast-chart article {
    display: grid;
    gap: 4px;
    grid-template-rows: minmax(210px, 1fr) auto auto auto;
    min-width: 90px;
    text-align: center;
}

.crm-forecast-bars {
    align-items: end;
    border-bottom: 1px solid #dfe4ec;
    display: flex;
    gap: 5px;
    justify-content: center;
}

.crm-forecast-bars i {
    border-radius: 6px 6px 0 0;
    height: var(--height);
    min-height: 0;
    transition: height .2s ease;
    width: min(28px, 34%);
}

.crm-forecast-chart strong { font-size: 12px; }
.crm-forecast-chart span,
.crm-forecast-chart small { color: #7c879b; font-size: 10px; }

.crm-insight-method {
    align-items: flex-start;
    background: #f5f7fb;
    border-left: 3px solid #8295cf;
    border-radius: 0 10px 10px 0;
    display: flex;
    gap: 12px;
    padding: 12px 14px;
}

.crm-insight-method strong { color: #43516c; flex: 0 0 auto; font-size: 12px; }
.crm-insight-method p { color: #667085; font-size: 12px; line-height: 1.6; margin: 0; }

.crm-insight-empty,
.crm-insight-error,
.crm-insight-loading {
    align-items: center;
    background: #fff;
    border: 1px dashed #cfd7e6;
    border-radius: 16px;
    color: #667085;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    min-height: 220px;
    padding: 28px;
    text-align: center;
}

.crm-insight-empty > span,
.crm-insight-error > span { color: #7182b3; font-size: 30px; }
.crm-insight-empty p,
.crm-insight-error p { line-height: 1.6; margin: 0; }
.crm-insight-error { border-style: solid; }
.crm-insight-error > div { display: grid; gap: 9px; justify-items: center; }
.crm-insight-loading { flex-direction: row; }
.crm-insight-loading i { animation: crmInsightPulse 1.2s infinite ease-in-out; background: #6780d6; border-radius: 99px; height: 8px; width: 8px; }
.crm-insight-loading i:nth-child(2) { animation-delay: .15s; }
.crm-insight-loading i:nth-child(3) { animation-delay: .3s; }

.crm-insight-pagination {
    align-items: center;
    color: #6f7a90;
    display: flex;
    font-size: 12px;
    justify-content: space-between;
}

.crm-insight-pagination > div { display: flex; gap: 8px; }

@keyframes crmInsightPulse {
    0%, 80%, 100% { opacity: .35; transform: scale(.75); }
    40% { opacity: 1; transform: scale(1); }
}

@media (max-width: 1100px) {
    .crm-health-grid { grid-template-columns: 1fr; }
    .crm-renewal-list > article { grid-template-columns: 130px minmax(0, 1fr); }
    .crm-renewal-actions { grid-column: 2; grid-row: 2; justify-items: start; }
}

@media (max-width: 760px) {
    .crm-insight { gap: 14px; }
    .crm-insight-hero { display: grid; gap: 16px; min-height: 0; padding: 22px; }
    .crm-insight-hero-badges { justify-content: flex-start; }
    .crm-insight-kpis { grid-template-columns: 1fr; }
    .crm-insight-kpis article { min-height: 96px; }
    .crm-insight-toolbar { align-items: stretch; display: grid; }
    .crm-insight-toolbar label { min-width: 0; }
    .crm-insight-toolbar button { width: 100%; }
    .crm-health-rule { align-items: flex-start; display: grid; }
    .crm-health-rule span { border-left: 0; border-top: 1px solid #d6deed; padding: 8px 0 0; }
    .crm-health-evidence { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .crm-renewal-list > article { align-items: start; grid-template-columns: 1fr; }
    .crm-renewal-actions { grid-column: 1; grid-row: auto; justify-items: start; }
    .crm-insight-pagination { align-items: stretch; display: grid; gap: 10px; }
    .crm-insight-pagination > div { display: grid; grid-template-columns: 1fr 1fr; }
    .crm-insight-method { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
    .crm-insight-loading i,
    .crm-forecast-bars i { animation: none; transition: none; }
}
