/**
 * Clay Dashboard — estilos públicos.
 */

.clay-dashboard {
	margin: 1.25rem 0;
	font-size: 0.95rem;
	color: #1f2328;
	line-height: 1.5;
}

.clay-ico {
	display: inline-block;
	vertical-align: -0.15em;
	flex: 0 0 auto;
}

/* ---------------------------------------------------------------- Panel */
.clay-panel {
	background: transparent;
}

.clay-panel__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	padding: 0.35rem 0 0.85rem;
	border-bottom: 1px solid #e2e8f0;
	margin-bottom: 0.85rem;
}

.clay-panel__brand {
	display: flex;
	align-items: center;
	gap: 0.65rem;
}

.clay-panel__brand > .clay-ico {
	color: #1f6feb;
	background: #eff6ff;
	width: 38px;
	height: 38px;
	padding: 9px;
	border-radius: 11px;
}

.clay-panel__title {
	display: block;
	font-size: 1.15rem;
	font-weight: 800;
	color: #0f172a;
	letter-spacing: -0.01em;
}

.clay-panel__sub {
	display: block;
	font-size: 0.78rem;
	color: #64748b;
}

.clay-quota {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.3rem 0.7rem;
	border-radius: 999px;
	background: #ecfdf5;
	color: #047857;
	font-size: 0.76rem;
	font-weight: 700;
	border: 1px solid #a7f3d0;
	white-space: nowrap;
}

.clay-quota.is-low {
	background: #fef2f2;
	color: #b91c1c;
	border-color: #fecaca;
}

/* ---------------------------------------------------------- Progress bar */
.clay-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 100000;
	background: transparent;
	overflow: hidden;
}

.clay-progress[hidden] {
	display: none;
}

.clay-progress > span {
	display: block;
	height: 100%;
	width: 40%;
	background: linear-gradient(90deg, #1f6feb, #38bdf8, #1f6feb);
	animation: clay-indeterminate 1.1s ease-in-out infinite;
	border-radius: 3px;
}

@keyframes clay-indeterminate {
	0% { transform: translateX(-100%); }
	100% { transform: translateX(350%); }
}

.clay-panel.is-loading .clay-tab-panel {
	opacity: 0.45;
	filter: saturate(0.7);
	transition: opacity 0.15s ease;
	pointer-events: none;
}

/* ---------------------------------------------------------------- Tabs */
.clay-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	padding: 0.3rem;
	background: #f1f5f9;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	margin-bottom: 1rem;
}

.clay-tab {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.5rem 0.85rem;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: #475569;
	font-size: 0.86rem;
	font-weight: 600;
	text-decoration: none;
	line-height: 1.1;
	transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.clay-tab .clay-ico {
	opacity: 0.8;
}

.clay-tab:hover {
	background: #e2e8f0;
	color: #0f172a;
	text-decoration: none;
}

.clay-tab.is-active {
	background: #1f6feb;
	color: #fff;
	box-shadow: 0 2px 8px rgba(31, 111, 235, 0.35);
}

.clay-tab.is-active .clay-ico {
	opacity: 1;
}

.clay-tab:focus-visible {
	outline: 2px solid #1f6feb;
	outline-offset: 2px;
}

/* ------------------------------------------------------------- Widgets */
.clay-widgets {
	display: grid;
	gap: 1rem;
	grid-template-columns: 1fr;
}

.clay-widget {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 1rem 1.1rem;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
	overflow: hidden;
}

.clay-widget__head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 0.6rem;
}

.clay-widget__head > .clay-ico {
	color: #1f6feb;
}

.clay-widget__title {
	margin: 0;
	font-size: 0.98rem;
	font-weight: 700;
	color: #0f172a;
	letter-spacing: -0.005em;
}

.clay-widget__body {
	min-width: 0;
}

.clay-risk__grid {
	display: grid;
	grid-template-columns: 1fr 1.25fr;
	gap: 1rem;
	margin: 1rem 0;
}

/* ----------------------------------------------------------------- KPI */
.clay-kpi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 0.75rem;
	margin: 0.75rem 0;
}

.clay-kpi {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	padding: 0.85rem 1rem;
	background: linear-gradient(180deg, #f8fafc, #f1f5f9);
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	min-width: 0;
}

.clay-kpi__icon {
	position: absolute;
	top: 0.65rem;
	right: 0.7rem;
	color: #1f6feb;
	opacity: 0.5;
}

.clay-kpi__label {
	font-size: 0.74rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #64748b;
	font-weight: 600;
}

.clay-kpi__value {
	font-size: 1.2rem;
	font-weight: 800;
	color: #0f172a;
	letter-spacing: -0.01em;
	overflow-wrap: anywhere;
}

.clay-kpi--warn .clay-kpi__value {
	color: #b91c1c;
}

.clay-kpi--warn {
	background: linear-gradient(180deg, #fff, #fef2f2);
	border-color: #fecaca;
}

/* ---------------------------------------------------------------- Tables */
.clay-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0.5rem 0 0.75rem;
	font-size: 0.88rem;
}

.clay-table th,
.clay-table td {
	padding: 0.5rem 0.6rem;
	border-bottom: 1px solid #eef2f7;
	text-align: left;
	vertical-align: top;
}

.clay-table th {
	background: #f8fafc;
	font-weight: 600;
	color: #475569;
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	white-space: nowrap;
}

.clay-table tbody tr:hover {
	background: #f8fafc;
}

.clay-table .clay-num {
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.clay-pos {
	color: #166534;
	font-weight: 600;
}

.clay-neg {
	color: #b91c1c;
	font-weight: 600;
}

/* ----------------------------------------------------------------- Text */
.clay-foot {
	margin: 0.4rem 0 0;
	font-size: 0.76rem;
	color: #94a3b8;
}

.clay-foot--warn {
	color: #b45309;
}

.clay-center {
	text-align: center;
}

.clay-hint {
	font-size: 0.78rem;
	color: #64748b;
}

.clay-dashboard--notice {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.85rem 1rem;
	background: #fff7ed;
	border: 1px solid #fed7aa;
	border-radius: 10px;
	color: #9a3412;
}

/* -------------------------------------------------------------- Charts */
.clay-chart {
	width: 100%;
	margin: 0.25rem 0 0.5rem;
}

.clay-svg {
	width: 100%;
	height: auto;
	display: block;
	overflow: visible;
}

.clay-svg__grid {
	stroke: #eef2f7;
	stroke-width: 1;
}

.clay-svg__axis {
	fill: #94a3b8;
	font-size: 11px;
	font-family: inherit;
}

.clay-svg__x {
	fill: #64748b;
	font-size: 11px;
	font-family: inherit;
}

.clay-svg__val {
	fill: #334155;
	font-size: 10px;
	font-weight: 700;
	font-family: inherit;
}

.clay-svg__bar {
	fill: #3b82f6;
	transition: fill 0.15s ease;
}

.clay-svg__bar:hover {
	fill: #1d4ed8;
}

.clay-svg__area {
	fill: rgba(31, 111, 235, 0.12);
}

.clay-svg__line {
	fill: none;
	stroke: #1f6feb;
	stroke-width: 2.5;
	stroke-linejoin: round;
	stroke-linecap: round;
}

.clay-svg__dot {
	fill: #1f6feb;
	stroke: #fff;
	stroke-width: 1.5;
}

.clay-svg--donut {
	max-width: 210px;
	margin: 0 auto;
}

.clay-svg--donut .clay-svg__seg {
	transition: opacity 0.15s ease;
}

.clay-svg--donut .clay-svg__seg:hover {
	opacity: 0.78;
}

.clay-svg__center {
	fill: #0f172a;
	font-size: 20px;
	font-weight: 800;
	font-family: inherit;
}

.clay-svg__sublabel {
	fill: #64748b;
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-family: inherit;
}

.clay-svg--gauge {
	max-width: 270px;
	margin: 0 auto;
}

.clay-chart-duo {
	display: grid;
	grid-template-columns: minmax(150px, 210px) 1fr;
	gap: 1rem;
	align-items: center;
}

.clay-legend__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.4rem;
	min-width: 0;
}

.clay-legend__list li {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.83rem;
	min-width: 0;
}

.clay-legend__dot {
	width: 10px;
	height: 10px;
	border-radius: 3px;
	flex: 0 0 auto;
}

.clay-legend__label {
	flex: 1;
	color: #334155;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.clay-legend__val {
	font-variant-numeric: tabular-nums;
	color: #64748b;
	font-weight: 600;
}

/* --------------------------------------------------------- API usage */
.clay-api-foot {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	margin-top: 0.7rem;
	padding-top: 0.55rem;
	border-top: 1px dashed #e2e8f0;
	font-size: 0.72rem;
	color: #94a3b8;
	line-height: 1.35;
}

.clay-api-foot .clay-ico {
	color: #cbd5e1;
}

.clay-api-foot.is-low {
	color: #b91c1c;
}

.clay-api-foot.is-low .clay-ico {
	color: #f87171;
}

/* ------------------------------------------------------------- Badges */
.clay-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.22rem 0.65rem;
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 700;
	white-space: nowrap;
}

.clay-badge--verde { background: #dcfce7; color: #166534; }
.clay-badge--amarillo { background: #fef9c3; color: #854d0e; }
.clay-badge--rojo { background: #fee2e2; color: #991b1b; }
.clay-badge--neutro { background: #e5e7eb; color: #374151; }

/* ------------------------------------------------------- Evaluación */
.clay-eval__hero {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1.15rem 1.25rem;
	border-radius: 14px;
	background: linear-gradient(135deg, #eff6ff, #f8fafc);
	border: 1px solid #dbeafe;
	margin-bottom: 1rem;
}

.clay-eval__icon {
	width: 58px;
	height: 58px;
	border-radius: 15px;
	background: #1f6feb;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	box-shadow: 0 6px 16px rgba(31, 111, 235, 0.3);
}

.clay-eval__title {
	margin: 0;
	font-size: 1.35rem;
	font-weight: 800;
	color: #0f172a;
	letter-spacing: -0.01em;
}

.clay-eval__lead {
	margin: 0.15rem 0 0;
	color: #475569;
	font-size: 0.9rem;
}

.clay-eval-form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 1rem;
	padding: 0.9rem 1rem;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
}

.clay-eval-form label {
	font-weight: 600;
	color: #334155;
	font-size: 0.85rem;
}

.clay-eval-form input[type="text"] {
	min-width: 180px;
	padding: 0.45rem 0.65rem;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font-size: 0.92rem;
}

.clay-eval-form input[type="text"]:focus {
	outline: 2px solid #1f6feb;
	outline-offset: 1px;
	border-color: #1f6feb;
}

.clay-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.5rem 0.95rem;
	background: #1f6feb;
	color: #fff;
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
	font-size: 0.9rem;
	line-height: 1.1;
	transition: background 0.15s ease;
}

.clay-btn:hover {
	background: #1a5fd0;
}

.clay-btn:disabled {
	opacity: 0.65;
	cursor: progress;
}

.clay-inline-loading {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.8rem;
	color: #1f6feb;
	font-weight: 600;
}

.clay-inline-loading[hidden] {
	display: none;
}

.clay-inline-loading::before {
	content: "";
	width: 13px;
	height: 13px;
	border: 2px solid #bfdbfe;
	border-top-color: #1f6feb;
	border-radius: 50%;
	animation: clay-spin 0.7s linear infinite;
}

@keyframes clay-spin {
	to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------- Risk */
.clay-risk {
	margin-top: 0.5rem;
}

.clay-risk__head {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	padding: 1rem 1.1rem;
	border-radius: 12px;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	margin-bottom: 0.5rem;
	flex-wrap: wrap;
}

.clay-risk--rojo .clay-risk__head { background: #fef2f2; border-color: #fecaca; }
.clay-risk--amarillo .clay-risk__head { background: #fffbeb; border-color: #fde68a; }
.clay-risk--verde .clay-risk__head { background: #f0fdf4; border-color: #bbf7d0; }

.clay-risk__avatar {
	width: 50px;
	height: 50px;
	border-radius: 13px;
	background: #fff;
	border: 1px solid #e2e8f0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #1f6feb;
	flex: 0 0 auto;
}

.clay-risk__id {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.clay-risk__name {
	font-size: 1.1rem;
	font-weight: 800;
	color: #0f172a;
	overflow-wrap: anywhere;
}

.clay-risk__rut {
	font-size: 0.82rem;
	color: #64748b;
}

.clay-risk__stats {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 1.25rem;
	font-size: 0.8rem;
	color: #475569;
	padding: 0.6rem 0.2rem;
	border-top: 1px solid #eef2f7;
}

/* -------------------------------------------------------------- Docs */
.clay-docs h2 {
	margin: 0.25rem 0 0.75rem;
	font-size: 1.5rem;
	font-weight: 800;
	color: #0f172a;
}

.clay-docs h3 {
	margin: 1.5rem 0 0.5rem;
	font-size: 1.1rem;
	font-weight: 700;
	color: #0f172a;
}

.clay-docs p,
.clay-docs li {
	color: #334155;
}

.clay-docs code {
	background: #f1f5f9;
	border: 1px solid #e2e8f0;
	border-radius: 5px;
	padding: 0.1rem 0.35rem;
	font-size: 0.85em;
	color: #0f172a;
}

.clay-code {
	display: block;
	background: #0f172a;
	color: #e2e8f0;
	padding: 0.85rem 1rem;
	border-radius: 10px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.82rem;
	overflow-x: auto;
	margin: 0.5rem 0 1rem;
	white-space: pre;
}

.clay-list {
	margin: 0.35rem 0 1rem;
	padding-left: 1.2rem;
}

.clay-list li {
	margin: 0.25rem 0;
}

/* ---------------------------------------------------------- Facturas */
.clay-facturas {
	margin-top: 0.25rem;
}

.clay-filters {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 0.9rem 1rem;
	margin-bottom: 1rem;
}

.clay-filters__row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1rem;
	margin-bottom: 0.65rem;
}

.clay-field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	font-size: 0.76rem;
	font-weight: 700;
	color: #475569;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.clay-field input,
.clay-field select {
	padding: 0.35rem 0.5rem;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font-size: 0.86rem;
	min-width: 120px;
	background: #fff;
	color: #0f172a;
}

.clay-types {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem 1rem;
	border: 1px dashed #e2e8f0;
	border-radius: 10px;
	padding: 0.5rem 0.75rem;
	margin: 0 0 0.75rem;
}

.clay-types legend {
	font-size: 0.76rem;
	font-weight: 700;
	color: #475569;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	padding: 0 0.3rem;
}

.clay-check {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.82rem;
	color: #334155;
}

.clay-filters__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
}

.clay-filters__hint {
	font-size: 0.76rem;
	color: #94a3b8;
}

.clay-export {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
	margin: 0.35rem 0 0.6rem;
}

.clay-btn--primary {
	background: #1f6feb;
	color: #fff;
}

.clay-btn--mini {
	padding: 0.28rem 0.55rem;
	font-size: 0.76rem;
	border-radius: 6px;
	background: #eff6ff;
	color: #1d4ed8;
	text-decoration: none;
}

.clay-btn--mini:hover {
	background: #dbeafe;
	color: #1e40af;
}

.clay-table-wrap {
	overflow-x: auto;
	border: 1px solid #eef2f7;
	border-radius: 10px;
}

.clay-table--facturas td,
.clay-table--facturas th {
	white-space: nowrap;
}

.clay-table--facturas td:nth-child(4) {
	white-space: normal;
	min-width: 180px;
}

.clay-actions {
	display: flex;
	gap: 0.3rem;
	align-items: center;
}

.clay-detail-row td {
	background: #f8fafc;
	padding: 0.75rem 0.9rem;
}

.clay-detail__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 0.5rem 1rem;
	margin: 0 0 0.5rem;
}

.clay-detail__grid dt {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #94a3b8;
	font-weight: 700;
}

.clay-detail__grid dd {
	margin: 0.1rem 0 0;
	font-size: 0.85rem;
	color: #0f172a;
}

.clay-detail__label {
	margin: 0.5rem 0 0.2rem;
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #94a3b8;
	font-weight: 700;
}

.clay-pager {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 0.25rem 0 0.75rem;
}

.clay-pager__info {
	font-size: 0.82rem;
	color: #475569;
	font-weight: 600;
}

.clay-pager .is-disabled {
	background: #e5e7eb;
	color: #94a3b8;
	cursor: default;
}

/* -------------------------------------------------------- Responsive */
@media (max-width: 782px) {
	.clay-risk__grid {
		grid-template-columns: 1fr;
	}

	.clay-chart-duo {
		grid-template-columns: 1fr;
	}

	.clay-tabs {
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.clay-tab {
		flex: 0 0 auto;
	}
}

@media (max-width: 600px) {
	.clay-table thead {
		display: none;
	}

	.clay-table tr {
		display: block;
		border-bottom: 1px solid #e5e7eb;
		padding: 0.35rem 0;
	}

	.clay-table td {
		display: flex;
		justify-content: space-between;
		gap: 0.75rem;
		border: 0;
		padding: 0.25rem 0;
	}

	.clay-kpi-grid {
		grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	}

	.clay-eval__hero {
		flex-direction: column;
		text-align: center;
	}
}

/* ====================================================================== */
/* Buscador de clientes (nombre o RUT parcial)                            */
/* ====================================================================== */

.clay-field--search {
	width: 100%;
}

.clay-search {
	position: relative;
	width: 100%;
}

.clay-search input[type="text"] {
	width: 100%;
	padding: 0.4rem 0.55rem;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font-size: 0.9rem;
	font-weight: 400;
	text-transform: none;
	letter-spacing: normal;
	background: #fff;
	color: #0f172a;
}

.clay-search input[type="text"]:focus {
	outline: 2px solid #2563eb;
	outline-offset: 1px;
	border-color: #2563eb;
}

.clay-search__list {
	position: absolute;
	z-index: 40;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	margin: 0;
	padding: 0.25rem;
	list-style: none;
	background: #fff;
	border: 1px solid #cbd5e1;
	border-radius: 10px;
	box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
	max-height: 320px;
	overflow-y: auto;
}

.clay-search__item {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.75rem;
	padding: 0.42rem 0.55rem;
	border-radius: 7px;
	cursor: pointer;
	font-size: 0.86rem;
	font-weight: 400;
	text-transform: none;
	letter-spacing: normal;
	color: #0f172a;
}

.clay-search__item:hover,
.clay-search__item:focus {
	background: #eff6ff;
	outline: none;
}

.clay-search__name {
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.clay-search__rut {
	color: #64748b;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.clay-search__hint {
	display: block;
	margin-top: 0.2rem;
	font-size: 0.72rem;
	font-weight: 400;
	text-transform: none;
	letter-spacing: normal;
	color: #64748b;
}

.clay-search__results {
	margin: 0.75rem 0 1rem;
	overflow-x: auto;
}

.clay-btn--mini {
	padding: 0.18rem 0.5rem;
	font-size: 0.76rem;
	white-space: nowrap;
}

.clay-eval-form .clay-field--search {
	flex: 1 1 20rem;
	min-width: 15rem;
}
