/* Home (main_dashboard): cards, indicadores e listas dos blocos carregados por turbo-frame. */
.home-dashboard {
	--home-radius: 1rem;
	--home-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
	--home-muted: var(--bs-secondary-color, #74788d);
	--home-soft: rgba(var(--bs-secondary-rgb), .08);
	font-variant-numeric: tabular-nums;
}

.home-dashboard .min-w-0 { min-width: 0; }

/* Cabeçalho */
.home-greeting {
	font-size: 1.35rem;
	font-weight: 700;
	letter-spacing: -.01em;
}

.home-period {
	display: inline-flex;
	padding: .25rem;
	gap: .125rem;
	border-radius: 999px;
	background: var(--bs-body-bg);
	border: 1px solid rgba(var(--bs-secondary-rgb), .15);
	box-shadow: var(--home-shadow);
}

.home-period-item {
	padding: .35rem .85rem;
	border-radius: 999px;
	font-size: .8rem;
	font-weight: 600;
	color: var(--home-muted);
	white-space: nowrap;
	transition: background-color .15s ease, color .15s ease;
}

.home-period-item:hover { color: var(--bs-body-color); background: var(--home-soft); }
.home-period-item.active { color: #fff; background: var(--bs-primary); }

/* Seletor de unidade (painel financeiro da franqueadora) */
.home-unit { min-width: 16rem; }

/* Sem label: anula o visual de float label que o layout.css aplica a todo select2 simples */
.home-unit .select2-container .select2-selection--single {
	height: 2.5rem !important;
	padding-top: 0 !important;
	padding-bottom: 0 !important;
	display: flex !important;
	align-items: center;
	font-size: .875rem !important;
}

.home-unit .select2-container .select2-selection--single .select2-selection__rendered {
	padding-left: 0;
	line-height: 1.5;
}

.home-chip {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	padding: .35rem .8rem;
	border-radius: 999px;
	font-size: .8rem;
	font-weight: 600;
}

.home-chip-success { color: var(--bs-success); background: rgba(var(--bs-success-rgb), .12); }
.home-chip-muted { color: var(--home-muted); background: var(--home-soft); }

.home-chip-dot {
	width: .5rem;
	height: .5rem;
	border-radius: 50%;
	background: currentColor;
	box-shadow: 0 0 0 0 currentColor;
	animation: home-pulse 2s infinite;
}

@keyframes home-pulse {
	0% { box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), .5); }
	70% { box-shadow: 0 0 0 .4rem rgba(var(--bs-success-rgb), 0); }
	100% { box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), 0); }
}

/* Cards */
.home-card {
	border: 1px solid rgba(var(--bs-secondary-rgb), .12);
	border-radius: var(--home-radius);
	box-shadow: var(--home-shadow);
}

.home-card-header {
	background: transparent;
	border-bottom: 0;
	padding: 1.1rem 1.25rem 0;
}

.home-card-title {
	display: flex;
	align-items: center;
	gap: .5rem;
	font-size: .95rem;
	font-weight: 600;
	margin: 0 0 .15rem;
}

.home-card-icon {
	font-size: 1.15rem;
	color: var(--bs-primary);
}

.home-subtitle {
	font-size: .72rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--home-muted);
	margin-bottom: .75rem;
}

.home-chart { min-height: 300px; }

/* Variação sobre o período anterior */
.home-delta {
	display: inline-flex;
	align-items: center;
	gap: .2rem;
	padding: .1rem .5rem;
	border-radius: 999px;
	font-size: .75rem;
	font-weight: 600;
	white-space: nowrap;
}

.home-delta .icon { font-size: 1rem; }

.home-comparison {
	font-size: .78rem;
	color: var(--home-muted);
}
.home-delta-good { background: rgba(var(--bs-success-rgb), .12); color: var(--bs-success); }
.home-delta-bad { background: rgba(var(--bs-danger-rgb), .12); color: var(--bs-danger); }
.home-delta-neutral { background: var(--home-soft); color: var(--home-muted); }

/* Listas, barras e distribuição */
.home-list > li { padding: .65rem 0; border-bottom: 1px dashed rgba(var(--bs-secondary-rgb), .18); }
.home-list > li:first-child { padding-top: 0; }
.home-list > li:last-child { padding-bottom: 0; border-bottom: 0; }
.home-list-compact > li { padding: .45rem 0; }

.home-scroll { max-height: 13rem; overflow-y: auto; scrollbar-width: thin; }

.home-distribution {
	display: flex;
	height: .6rem;
	border-radius: 999px;
	overflow: hidden;
	gap: 2px;
	background: var(--home-soft);
}

.home-dot {
	width: .6rem;
	height: .6rem;
	border-radius: 50%;
	flex-shrink: 0;
}

.home-bar {
	height: .4rem;
	border-radius: 999px;
	background: var(--home-soft);
	overflow: hidden;
}

.home-bar > div {
	height: 100%;
	border-radius: 999px;
	background: var(--bs-primary);
}

.home-rank {
	width: 1.75rem;
	height: 1.75rem;
	border-radius: .5rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: .75rem;
	font-weight: 700;
	color: var(--home-muted);
	background: var(--home-soft);
}

.home-rank-top { color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), .12); }

.home-product-photo {
	width: 2.5rem;
	height: 2.5rem;
	border-radius: .6rem;
	object-fit: cover;
	flex-shrink: 0;
	background: var(--home-soft);
}

.home-avatar {
	width: 2.25rem;
	height: 2.25rem;
	border-radius: .6rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-weight: 700;
	color: var(--bs-primary);
	background: rgba(var(--bs-primary-rgb), .1);
}

.home-stat {
	display: flex;
	align-items: center;
	gap: .5rem;
	padding: .55rem .75rem;
	border-radius: .75rem;
	background: var(--home-soft);
}

.home-soft-badge {
	display: inline-block;
	padding: .3em .65em;
	border-radius: 999px;
	font-size: .72rem;
	font-weight: 600;
	white-space: nowrap;
	color: var(--badge-color);
	background: color-mix(in srgb, var(--badge-color) 14%, transparent);
}

.home-table thead th {
	font-size: .7rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--home-muted);
	white-space: nowrap;
	border-bottom: 1px solid rgba(var(--bs-secondary-rgb), .15);
}

.home-table tbody tr + tr td { border-top: 1px dashed rgba(var(--bs-secondary-rgb), .18); }

.home-empty-icon { font-size: 2.25rem; color: rgba(var(--bs-secondary-rgb), .45); }

/* Pendências da unidade */
.home-alerts {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: .75rem;
}

.home-alert {
	--alert-color: var(--bs-info);
	display: flex;
	align-items: center;
	gap: .75rem;
	padding: .8rem 1rem;
	border-radius: var(--home-radius);
	border: 1px solid color-mix(in srgb, var(--alert-color) 25%, transparent);
	background: color-mix(in srgb, var(--alert-color) 7%, var(--bs-body-bg));
	color: var(--bs-body-color);
	transition: transform .15s ease, box-shadow .15s ease;
}

a.home-alert:hover { color: var(--bs-body-color); transform: translateY(-1px); box-shadow: var(--home-shadow); }

.home-alert-danger { --alert-color: var(--bs-danger); }
.home-alert-warning { --alert-color: var(--bs-warning); }
.home-alert-info { --alert-color: var(--bs-info); }

.home-alert-icon {
	width: 2.25rem;
	height: 2.25rem;
	border-radius: .65rem;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: var(--alert-color);
	background: color-mix(in srgb, var(--alert-color) 15%, transparent);
}

/* Bloco recarregando dentro do próprio frame (ex.: paginação): o Turbo marca o frame com aria-busy */
.dashboard-widget-loading {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	border-radius: var(--home-radius);
	background: rgba(var(--bs-body-bg-rgb), .6);
}

.dashboard-widget[aria-busy="true"] .dashboard-widget-loading { display: flex; }
.dashboard-widget[aria-busy="true"] .home-card .card-body { pointer-events: none; }

/* Esqueleto exibido enquanto o bloco carrega */
.home-skeleton {
	display: block;
	height: .75rem;
	border-radius: .4rem;
	background: linear-gradient(90deg, var(--home-soft) 25%, rgba(var(--bs-secondary-rgb), .16) 50%, var(--home-soft) 75%);
	background-size: 200% 100%;
	animation: home-shimmer 1.4s ease-in-out infinite;
}

.home-skeleton-lg { height: 1.2rem; }
.home-skeleton-block { height: 14rem; }
.home-skeleton-card { min-height: 9rem; }

@keyframes home-shimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
	.home-skeleton, .home-chip-dot { animation: none; }
}

@media (max-width: 575.98px) {
	.home-period { width: 100%; overflow-x: auto; }
	.home-unit { width: 100%; min-width: 0; }
	.home-period-item { flex: 1 0 auto; text-align: center; }
}
