/*
  Dashboard CRM (Corte 2A-4). Usa apenas tokens --crm-* e graficos SVG/CSS proprios.
*/

.crm-dashboard-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 18px;
    align-content: start;
}

.crm-dashboard-page > .crm-page-header,
.crm-dashboard-page > .crm-dashboard-kpi-grid,
.crm-dashboard-page > .crm-dashboard-loading,
.crm-dashboard-page > .crm-dashboard-empty-state,
.crm-dashboard-page > .crm-empty-state {
    grid-column: 1 / -1;
}

.crm-dashboard-period-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    background: var(--crm-color-surface);
}

.crm-dashboard-period-filter button {
    height: 30px;
    border: 0;
    border-radius: var(--crm-radius-sm);
    padding: 0 12px;
    background: transparent;
    color: var(--crm-color-text-muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.crm-dashboard-period-filter button:hover {
    background: var(--crm-color-primary-soft);
    color: var(--crm-color-primary-soft-text);
}

.crm-dashboard-period-filter button.active {
    background: var(--crm-color-primary);
    color: var(--crm-color-on-primary);
}

.crm-dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.crm-dashboard-kpi-card,
.crm-dashboard-chart-card {
    min-width: 0;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    background: var(--crm-color-surface);
    color: var(--crm-color-text);
    box-shadow: var(--crm-shadow-sm);
}

.crm-dashboard-kpi-card {
    position: relative;
    overflow: hidden;
    min-height: 120px;
    padding: 14px;
    border-top-width: 3px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.crm-dashboard-kpi-card.tone-primary { border-top-color: var(--crm-color-primary); }
.crm-dashboard-kpi-card.tone-success { border-top-color: var(--crm-color-success); }
.crm-dashboard-kpi-card.tone-warning { border-top-color: var(--crm-color-warning); }
.crm-dashboard-kpi-card.tone-danger { border-top-color: var(--crm-color-danger); }
.crm-dashboard-kpi-card.tone-info { border-top-color: var(--crm-color-info); }
.crm-dashboard-kpi-card.tone-accent { border-top-color: var(--crm-color-accent); }
.crm-dashboard-kpi-card.tone-purple { border-top-color: #8b5cf6; }
.crm-dashboard-kpi-card.tone-neutral { border-top-color: var(--crm-color-border-strong); }

.crm-dashboard-kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.crm-dashboard-kpi-top > span:first-child {
    min-width: 0;
    color: var(--crm-color-text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.crm-dashboard-kpi-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--crm-radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--crm-color-primary-soft);
    color: var(--crm-color-primary-soft-text);
    flex: 0 0 auto;
}

.crm-dashboard-kpi-icon .crm-icon {
    width: 16px;
    height: 16px;
}

.crm-dashboard-kpi-card strong {
    display: block;
    font-size: 27px;
    line-height: 1;
    letter-spacing: 0;
    color: var(--crm-color-text);
}

.crm-dashboard-kpi-card p {
    margin: 0;
    color: var(--crm-color-text-muted);
    font-size: 12.5px;
    line-height: 1.35;
}

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

.crm-dashboard-side-grid {
    min-width: 0;
    display: grid;
    gap: 14px;
    align-content: start;
}

.crm-dashboard-chart-card {
    display: flex;
    flex-direction: column;
    min-height: 270px;
}

.crm-dashboard-chart-card header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px 12px;
    border-bottom: 1px solid var(--crm-color-border);
}

.crm-dashboard-chart-card h2 {
    margin: 0;
    font-size: 15px;
    line-height: 1.2;
    color: var(--crm-color-text);
}

.crm-dashboard-chart-card p {
    margin: 5px 0 0;
    color: var(--crm-color-text-muted);
    font-size: 12.5px;
}

.crm-dashboard-chart-card header > span {
    flex: 0 0 auto;
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    border-radius: var(--crm-radius-xl);
    padding: 3px 10px;
    background: var(--crm-color-primary-soft);
    color: var(--crm-color-primary-soft-text);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.crm-dashboard-chart-body {
    flex: 1 1 auto;
    min-width: 0;
    padding: 14px 16px 16px;
}

.crm-dashboard-line-chart,
.crm-dashboard-message-chart,
.crm-dashboard-bars,
.crm-dashboard-donut-wrap,
.crm-dashboard-agent-table,
.crm-dashboard-connection-list,
.crm-dashboard-metric-list {
    min-width: 0;
}

.crm-dashboard-line-chart svg {
    width: 100%;
    height: auto;
    display: block;
}

.crm-dashboard-line-area {
    fill: none;
    stroke: color-mix(in srgb, var(--crm-color-primary) 22%, transparent);
    stroke-width: 28;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.crm-dashboard-line-path {
    fill: none;
    stroke: var(--crm-color-primary);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.crm-dashboard-line-chart circle {
    fill: var(--crm-color-surface);
    stroke: var(--crm-color-primary);
    stroke-width: 3;
}

.crm-dashboard-chart-axis {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--crm-color-text-muted);
    font-size: 11.5px;
}

.crm-dashboard-bars {
    display: grid;
    gap: 12px;
}

.crm-dashboard-bar-row {
    display: grid;
    grid-template-columns: minmax(80px, 130px) minmax(0, 1fr) 34px;
    align-items: center;
    gap: 10px;
}

.crm-dashboard-bar-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--crm-color-text);
    font-size: 12.5px;
    font-weight: 600;
}

.crm-dashboard-bar-track {
    height: 9px;
    overflow: hidden;
    border-radius: var(--crm-radius-xl);
    background: var(--crm-color-app-bg);
}

.crm-dashboard-bar-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--crm-color-primary);
}

.crm-dashboard-bar-fill.tone-success { background: var(--crm-color-success); }
.crm-dashboard-bar-fill.tone-warning { background: var(--crm-color-warning); }
.crm-dashboard-bar-fill.tone-danger { background: var(--crm-color-danger); }
.crm-dashboard-bar-fill.tone-info { background: var(--crm-color-info); }
.crm-dashboard-bar-fill.tone-purple { background: #8b5cf6; }
.crm-dashboard-bar-fill.tone-neutral { background: var(--crm-color-border-strong); }

.crm-dashboard-bar-row strong {
    color: var(--crm-color-text);
    font-size: 12.5px;
    text-align: right;
}

.crm-dashboard-donut-wrap {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    align-items: center;
    gap: 18px;
}

.crm-dashboard-donut {
    width: 140px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
}

.crm-dashboard-donut::after {
    content: "";
    position: absolute;
    inset: 26px;
    border-radius: 50%;
    background: var(--crm-color-surface);
}

.crm-dashboard-donut span,
.crm-dashboard-donut small {
    position: relative;
    z-index: 1;
}

.crm-dashboard-donut span {
    margin-top: 8px;
    color: var(--crm-color-text);
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.crm-dashboard-donut small {
    margin-top: -42px;
    color: var(--crm-color-text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.crm-dashboard-legend,
.crm-dashboard-metric-list,
.crm-dashboard-connection-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.crm-dashboard-legend li,
.crm-dashboard-metric-list li {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
}

.crm-dashboard-legend li > span,
.crm-dashboard-metric-list li > span,
.crm-dashboard-mini-legend i {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    display: inline-block;
    background: var(--crm-color-primary);
}

.crm-dashboard-legend .tone-success,
.crm-dashboard-metric-list .tone-success { background: var(--crm-color-success); }
.crm-dashboard-legend .tone-warning,
.crm-dashboard-metric-list .tone-warning { background: var(--crm-color-warning); }
.crm-dashboard-legend .tone-danger,
.crm-dashboard-metric-list .tone-danger { background: var(--crm-color-danger); }
.crm-dashboard-legend .tone-info,
.crm-dashboard-metric-list .tone-info { background: var(--crm-color-info); }
.crm-dashboard-legend .tone-purple,
.crm-dashboard-metric-list .tone-purple { background: #8b5cf6; }
.crm-dashboard-legend .tone-neutral,
.crm-dashboard-metric-list .tone-neutral { background: var(--crm-color-border-strong); }

.crm-dashboard-legend p,
.crm-dashboard-metric-list p {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--crm-color-text);
    font-size: 12.5px;
    font-weight: 600;
}

.crm-dashboard-legend strong,
.crm-dashboard-metric-list strong {
    color: var(--crm-color-text);
    font-size: 12.5px;
}

.crm-dashboard-message-chart {
    height: 210px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(26px, 1fr));
    align-items: end;
    gap: 8px;
    padding-top: 8px;
}

.crm-dashboard-message-day {
    min-width: 0;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 8px;
    height: 100%;
}

.crm-dashboard-message-columns {
    min-height: 160px;
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 4px;
    border-bottom: 1px solid var(--crm-color-border);
}

.crm-dashboard-message-columns span {
    width: 8px;
    min-height: 3px;
    border-radius: var(--crm-radius-xl) var(--crm-radius-xl) 0 0;
}

.crm-dashboard-message-columns .inbound,
.crm-dashboard-mini-legend .inbound {
    background: var(--crm-color-primary);
}

.crm-dashboard-message-columns .outbound,
.crm-dashboard-mini-legend .outbound {
    background: var(--crm-color-success);
}

.crm-dashboard-message-day small {
    min-width: 0;
    overflow: hidden;
    text-align: center;
    color: var(--crm-color-text-muted);
    font-size: 10.5px;
}

.crm-dashboard-mini-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin-top: 10px;
    color: var(--crm-color-text-muted);
    font-size: 11.5px;
}

.crm-dashboard-mini-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.crm-dashboard-agent-table {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    display: grid;
    gap: 7px;
}

.crm-dashboard-agent-header,
.crm-dashboard-agent-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(34px, 38px) minmax(34px, 38px) minmax(42px, 48px) minmax(38px, 44px);
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.crm-dashboard-agent-header {
    color: var(--crm-color-text-muted);
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
}

.crm-dashboard-agent-row {
    min-height: 34px;
    border-radius: var(--crm-radius-sm);
    background: var(--crm-color-app-bg);
    padding: 0 7px;
    color: var(--crm-color-text);
    font-size: 12px;
}

.crm-dashboard-agent-header span,
.crm-dashboard-agent-row span,
.crm-dashboard-agent-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
}

.crm-dashboard-agent-row span:not(:first-child) {
    text-align: right;
    color: var(--crm-color-text-muted);
}

.crm-dashboard-connection-list li {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.crm-dashboard-connection-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--crm-radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--crm-color-primary-soft);
    color: var(--crm-color-primary-soft-text);
}

.crm-dashboard-connection-icon .crm-icon {
    width: 17px;
    height: 17px;
}

.crm-dashboard-connection-icon.tone-success {
    background: color-mix(in srgb, var(--crm-color-success) 14%, var(--crm-color-surface));
    color: var(--crm-color-success);
}

.crm-dashboard-connection-icon.tone-warning {
    background: color-mix(in srgb, var(--crm-color-warning) 14%, var(--crm-color-surface));
    color: var(--crm-color-warning);
}

.crm-dashboard-connection-icon.tone-danger {
    background: color-mix(in srgb, var(--crm-color-danger) 14%, var(--crm-color-surface));
    color: var(--crm-color-danger);
}

.crm-dashboard-connection-list strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--crm-color-text);
    font-size: 12.5px;
}

.crm-dashboard-connection-list p {
    margin: 2px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--crm-color-text-muted);
    font-size: 11.5px;
}

.crm-dashboard-status-pill {
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    border-radius: var(--crm-radius-xl);
    padding: 3px 10px;
    background: var(--crm-color-app-bg);
    color: var(--crm-color-text-muted);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.crm-dashboard-status-pill.tone-success {
    background: color-mix(in srgb, var(--crm-color-success) 12%, var(--crm-color-surface));
    color: var(--crm-color-success);
}

.crm-dashboard-status-pill.tone-warning {
    background: color-mix(in srgb, var(--crm-color-warning) 12%, var(--crm-color-surface));
    color: var(--crm-color-warning);
}

.crm-dashboard-status-pill.tone-danger {
    background: color-mix(in srgb, var(--crm-color-danger) 12%, var(--crm-color-surface));
    color: var(--crm-color-danger);
}

.crm-dashboard-empty-state {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    border: 1px dashed var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    background: color-mix(in srgb, var(--crm-color-surface) 88%, var(--crm-color-app-bg));
    padding: 18px;
}

.crm-dashboard-empty-state > span {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--crm-radius-md);
    background: var(--crm-color-primary-soft);
    color: var(--crm-color-primary-soft-text);
}

.crm-dashboard-empty-state .crm-icon {
    width: 18px;
    height: 18px;
}

.crm-dashboard-empty-state strong {
    color: var(--crm-color-text);
    font-size: 14px;
}

.crm-dashboard-empty-state p {
    max-width: 520px;
    margin: 0;
    color: var(--crm-color-text-muted);
    font-size: 12.5px;
    line-height: 1.45;
}

.crm-dashboard-loading {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.crm-dashboard-loading span {
    height: 120px;
    border-radius: var(--crm-radius-md);
    border: 1px solid var(--crm-color-border);
    background: linear-gradient(
        90deg,
        var(--crm-color-surface) 0%,
        var(--crm-color-app-bg) 45%,
        var(--crm-color-surface) 100%
    );
    animation: crmDashboardPulse 1.2s ease-in-out infinite;
}

@keyframes crmDashboardPulse {
    0%, 100% { opacity: .55; }
    50% { opacity: 1; }
}

.crm-operational-report {
    grid-column: 1 / -1;
    min-width: 0;
    display: grid;
    gap: 14px;
    margin-top: 4px;
    padding-top: 18px;
    border-top: 1px solid var(--crm-color-border);
}

.crm-operational-report-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.crm-operational-report-header h2,
.crm-operational-report-ai h3 {
    margin: 0;
    color: var(--crm-color-text);
}

.crm-operational-report-header h2 { font-size: 18px; }
.crm-operational-report-header p,
.crm-operational-report-period {
    margin: 4px 0 0;
    color: var(--crm-color-text-muted);
    font-size: 12.5px;
}

.crm-operational-report-filters {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    background: var(--crm-color-surface);
}

.crm-operational-report-filters label {
    min-width: 140px;
    display: grid;
    gap: 5px;
    color: var(--crm-color-text-muted);
    font-size: 11.5px;
    font-weight: 700;
}

.crm-operational-report-filters select,
.crm-operational-report-filters input {
    min-height: 36px;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-sm);
    padding: 0 10px;
    background: var(--crm-color-surface);
    color: var(--crm-color-text);
}

.crm-operational-report-apply {
    min-height: 36px;
    border: 0;
    border-radius: var(--crm-radius-sm);
    padding: 0 14px;
    background: var(--crm-color-primary);
    color: var(--crm-color-on-primary);
    font-weight: 700;
    cursor: pointer;
}

.crm-operational-report-apply:disabled { opacity: .65; cursor: wait; }

.crm-operational-report-error,
.crm-operational-report-loading {
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    padding: 12px 14px;
    background: var(--crm-color-surface);
    color: var(--crm-color-text-muted);
    font-size: 13px;
}

.crm-operational-report-error {
    border-color: color-mix(in srgb, var(--crm-color-danger) 35%, var(--crm-color-border));
    color: var(--crm-color-danger);
}

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

.crm-operational-report-table-wrap { width: 100%; overflow-x: auto; }

.crm-operational-report-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--crm-color-text);
    font-size: 12px;
}

.crm-operational-report-table th,
.crm-operational-report-table td {
    padding: 9px 8px;
    border-bottom: 1px solid var(--crm-color-border);
    text-align: right;
    white-space: nowrap;
}

.crm-operational-report-table th:first-child,
.crm-operational-report-table td:first-child { text-align: left; }
.crm-operational-report-table th { color: var(--crm-color-text-muted); font-weight: 700; }
.crm-operational-report-table small { display: block; color: var(--crm-color-text-muted); }

.crm-operational-report-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.crm-operational-report-metrics span {
    display: grid;
    gap: 3px;
    padding: 10px;
    border-radius: var(--crm-radius-sm);
    background: var(--crm-color-app-bg);
    color: var(--crm-color-text-muted);
    font-size: 11.5px;
}

.crm-operational-report-metrics strong { color: var(--crm-color-text); font-size: 18px; }

.crm-operational-report-list {
    width: 100%;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.crm-operational-report-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--crm-color-border);
    color: var(--crm-color-text);
    font-size: 12px;
}

.crm-operational-report-list strong { color: var(--crm-color-text-muted); font-weight: 600; }

.crm-operational-report-ai {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.crm-operational-report-ai > div {
    padding: 12px;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-sm);
}

.crm-operational-report-ai h3 { font-size: 13px; }
.crm-operational-report-ai p { margin: 7px 0 0; }

@media (max-width: 1023px) {
    .crm-operational-report-grid { grid-template-columns: minmax(0, 1fr); }
    .crm-operational-report-metrics,
    .crm-operational-report-ai { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
    .crm-operational-report-header { align-items: stretch; flex-direction: column; }
    .crm-operational-report-filters { display: grid; grid-template-columns: minmax(0, 1fr); }
    .crm-operational-report-filters label { min-width: 0; }
    .crm-operational-report-metrics,
    .crm-operational-report-ai { grid-template-columns: minmax(0, 1fr); }
}

.crm-dashboard-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.crm-dashboard-view-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    background: var(--crm-color-surface);
}

.crm-dashboard-view-switch button {
    height: 30px;
    border: 0;
    border-radius: var(--crm-radius-sm);
    padding: 0 12px;
    background: transparent;
    color: var(--crm-color-text-muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.crm-dashboard-view-switch button:hover {
    background: var(--crm-color-primary-soft);
    color: var(--crm-color-primary-soft-text);
}

.crm-dashboard-view-switch button.active {
    background: var(--crm-color-primary);
    color: var(--crm-color-on-primary);
}

.crm-dashboard-filter-select {
    height: 40px;
    max-width: 190px;
    min-width: 145px;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    background: var(--crm-color-surface);
    color: var(--crm-color-text);
    padding: 0 10px;
    font-size: 12.5px;
    font-weight: 500;
}

.crm-dashboard-kanban-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--crm-radius-md);
    padding: 0 13px;
    background: var(--crm-color-primary);
    color: var(--crm-color-on-primary);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.crm-dashboard-kanban-link:hover {
    background: var(--crm-color-primary-hover);
}

.crm-dashboard-main-grid.commercial {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-dashboard-side-grid.commercial {
    grid-template-columns: 1fr;
}

.crm-commercial-stage-list,
.crm-commercial-loss-list,
.crm-commercial-source-list,
.crm-commercial-forecast-list,
.crm-commercial-responsible-table,
.crm-commercial-activity-widget {
    min-width: 0;
}

.crm-commercial-stage-list {
    display: grid;
    gap: 10px;
}

.crm-commercial-stage-row {
    display: grid;
    grid-template-columns: 12px minmax(88px, 1fr) minmax(120px, 1.4fr) 42px 96px;
    align-items: center;
    gap: 9px;
    min-width: 0;
    color: var(--crm-color-text);
    text-decoration: none;
}

.crm-commercial-stage-row:hover .crm-commercial-stage-name {
    color: var(--crm-color-primary);
}

.crm-commercial-stage-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--crm-radius-xl);
    background: var(--crm-color-primary);
}

.crm-commercial-stage-name,
.crm-dashboard-bar-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-commercial-stage-track,
.crm-commercial-source-track {
    height: 8px;
    overflow: hidden;
    border-radius: var(--crm-radius-xl);
    background: color-mix(in srgb, var(--crm-color-border) 72%, transparent);
}

.crm-commercial-stage-fill,
.crm-commercial-source-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--crm-color-primary);
}

.crm-commercial-stage-row strong,
.crm-commercial-stage-row small {
    color: var(--crm-color-text);
    font-size: 12.5px;
    font-weight: 600;
    text-align: right;
}

.crm-dashboard-bar-row.commercial-link {
    color: var(--crm-color-text);
    text-decoration: none;
}

.crm-commercial-won-lost-chart {
    display: grid;
    gap: 12px;
}

.crm-commercial-won-lost-bars {
    height: 170px;
    display: flex;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
}

.crm-commercial-won-lost-point {
    flex: 1 1 0;
    min-width: 18px;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
}

.crm-commercial-won-lost-columns {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    min-height: 0;
    border-bottom: 1px solid var(--crm-color-border);
}

.crm-commercial-won-lost-columns span {
    width: 7px;
    min-height: 2px;
    border-radius: var(--crm-radius-xl) var(--crm-radius-xl) 0 0;
}

.crm-commercial-won-lost-columns .won,
.crm-commercial-chart-legend .won {
    background: var(--crm-color-success);
}

.crm-commercial-won-lost-columns .lost,
.crm-commercial-chart-legend .lost {
    background: var(--crm-color-danger);
}

.crm-commercial-won-lost-point small {
    color: var(--crm-color-text-muted);
    font-size: 10.5px;
    text-align: center;
}

.crm-commercial-chart-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--crm-color-text-muted);
    font-size: 12px;
}

.crm-commercial-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.crm-commercial-chart-legend i {
    width: 9px;
    height: 9px;
    border-radius: var(--crm-radius-xl);
}

.crm-commercial-loss-list {
    display: grid;
    gap: 9px;
}

.crm-commercial-loss-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px 54px 96px;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.crm-commercial-loss-row > div {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-commercial-loss-row span {
    width: 9px;
    height: 9px;
    border-radius: var(--crm-radius-xl);
    background: var(--crm-color-primary);
    flex: 0 0 auto;
}

.crm-commercial-loss-row span.tone-danger { background: var(--crm-color-danger); }
.crm-commercial-loss-row span.tone-warning { background: var(--crm-color-warning); }
.crm-commercial-loss-row span.tone-purple { background: var(--crm-color-info); }
.crm-commercial-loss-row span.tone-neutral { background: var(--crm-color-border-strong); }

.crm-commercial-loss-row p,
.crm-commercial-source-row strong,
.crm-commercial-forecast-row strong,
.crm-commercial-responsible-row strong {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-commercial-loss-row strong,
.crm-commercial-loss-row small,
.crm-commercial-loss-row em {
    color: var(--crm-color-text);
    font-size: 12px;
    font-style: normal;
    font-weight: 600;
    text-align: right;
}

.crm-commercial-activity-widget {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.crm-commercial-activity-widget a {
    min-width: 0;
    border: 1px solid var(--crm-color-border);
    border-radius: var(--crm-radius-md);
    padding: 11px;
    background: color-mix(in srgb, var(--crm-color-surface) 86%, var(--crm-color-app-bg));
    color: var(--crm-color-text);
    text-decoration: none;
}

.crm-commercial-activity-widget a:hover {
    border-color: var(--crm-color-primary-border);
    background: var(--crm-color-primary-soft);
}

.crm-commercial-activity-widget span {
    display: block;
    color: var(--crm-color-text-muted);
    font-size: 12px;
}

.crm-commercial-activity-widget strong {
    display: block;
    margin-top: 6px;
    font-size: 22px;
}

.crm-commercial-forecast-list,
.crm-commercial-source-list {
    display: grid;
    gap: 10px;
}

.crm-commercial-forecast-row,
.crm-commercial-source-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-width: 0;
    border-bottom: 1px solid var(--crm-color-border);
    padding-bottom: 10px;
    color: var(--crm-color-text);
    text-decoration: none;
}

.crm-commercial-source-row {
    grid-template-columns: minmax(0, 1fr) minmax(80px, 120px) 92px;
}

.crm-commercial-forecast-row:last-child,
.crm-commercial-source-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.crm-commercial-forecast-row span,
.crm-commercial-source-row span,
.crm-commercial-source-row em {
    color: var(--crm-color-text-muted);
    font-size: 12px;
    font-style: normal;
}

.crm-commercial-forecast-row > div:last-child {
    text-align: right;
}

.crm-commercial-source-row em {
    color: var(--crm-color-text);
    font-weight: 600;
    text-align: right;
}

.crm-commercial-responsible-table {
    display: grid;
    gap: 6px;
    overflow-x: auto;
}

.crm-commercial-responsible-head,
.crm-commercial-responsible-row {
    min-width: 560px;
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 58px 112px 58px 72px;
    align-items: center;
    gap: 8px;
}

.crm-commercial-responsible-head {
    color: var(--crm-color-text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.crm-commercial-responsible-row {
    min-height: 36px;
    color: var(--crm-color-text);
    text-decoration: none;
    font-size: 12.5px;
}

.crm-commercial-responsible-row:hover {
    color: var(--crm-color-primary);
}

.crm-commercial-responsible-row span:not(:first-child),
.crm-commercial-responsible-head span:not(:first-child) {
    text-align: right;
}

@media (max-width: 1023px) {
    .crm-dashboard-page {
        grid-template-columns: 1fr;
    }

    .crm-dashboard-side-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .crm-dashboard-kpi-grid,
    .crm-dashboard-main-grid,
    .crm-dashboard-side-grid,
    .crm-dashboard-loading {
        grid-template-columns: 1fr;
    }

    .crm-dashboard-donut-wrap {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .crm-commercial-stage-row,
    .crm-commercial-source-row,
    .crm-commercial-loss-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .crm-commercial-stage-row strong,
    .crm-commercial-stage-row small,
    .crm-commercial-loss-row strong,
    .crm-commercial-loss-row small,
    .crm-commercial-loss-row em {
        text-align: left;
    }
}

@media (max-width: 767px) {
    .crm-dashboard-page {
        gap: 12px;
    }

    .crm-dashboard-actions,
    .crm-dashboard-period-filter {
        width: 100%;
    }

    .crm-dashboard-view-switch,
    .crm-dashboard-filter-select,
    .crm-dashboard-kanban-link {
        width: 100%;
        max-width: none;
    }

    .crm-dashboard-view-switch button {
        flex: 1 1 0;
    }

    .crm-dashboard-period-filter button {
        flex: 1 1 0;
        padding: 0 8px;
    }

    .crm-commercial-activity-widget {
        grid-template-columns: 1fr;
    }

    .crm-dashboard-agent-header,
    .crm-dashboard-agent-row {
        grid-template-columns: minmax(0, 1fr) 38px 38px 46px;
    }

    .crm-dashboard-agent-header span:last-child,
    .crm-dashboard-agent-row span:last-child {
        display: none;
    }
}

/* UNICHAT-MOBILE-UX-ARCHITECTURE-01 (B6) — dashboard mobile: KPIs primeiro, checklist no fim. */
.crm-dashboard-mobile-controls { display: none; }
@media (max-width: 1023px) {
    .crm-dashboard-mobile-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
    .crm-dashboard-mobile-controls .uni-alert-chip { margin-bottom: 0; }
}
@media (max-width: 767px) {
    .crm-dashboard-page { display: flex; flex-direction: column; }
    .crm-dashboard-page > .crm-dashboard-checklist-slot { order: 99; }
}
