/* Comparar Archivos Excel — estilos del comparador. Todo va dentro de .diffsheet para no chocar con el tema. */

.diffsheet {
	--ds-accent: #0f766e;
	--ds-ink: #111827;
	--ds-muted: #6b7280;
	--ds-line: #e5e7eb;
	--ds-surface: #ffffff;
	--ds-soft: #f9fafb;
	--ds-mod: #fff2cc;
	--ds-mod-ink: #7a5b00;
	--ds-add: #e2f0d9;
	--ds-add-ink: #2f6b1a;
	--ds-del: #fce4e4;
	--ds-del-ink: #9c0006;
	--ds-radius: 14px;

	box-sizing: border-box;
	max-width: 960px;
	margin: 1.5em auto;
	color: var(--ds-ink);
	font-size: 16px;
	line-height: 1.5;
}
.diffsheet *, .diffsheet *::before, .diffsheet *::after { box-sizing: inherit; }
.diffsheet [hidden] { display: none !important; }
.diffsheet svg { flex: none; }

/* ---------- Tarjetas de archivo ---------- */

.ds-files {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 14px;
	align-items: stretch;
}
@media (max-width: 700px) {
	.ds-files { grid-template-columns: 1fr; }
	.ds-swap { justify-self: center; transform: rotate(90deg); }
}

.ds-slot {
	background: var(--ds-surface);
	border: 1px solid var(--ds-line);
	border-radius: var(--ds-radius);
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	min-width: 0;
}
.ds-slot.has-file { border-color: color-mix(in srgb, var(--ds-accent) 45%, var(--ds-line)); }

.ds-slot__head { display: flex; gap: 12px; align-items: flex-start; }
.ds-step {
	width: 30px; height: 30px; border-radius: 50%;
	display: grid; place-items: center;
	background: var(--ds-accent); color: #fff;
	font-weight: 700; font-size: 15px; flex: none;
}
.diffsheet .ds-slot__title { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 700; color: var(--ds-ink); }
.diffsheet .ds-slot__hint { margin: 2px 0 0; font-size: 14px; color: var(--ds-muted); }

.ds-drop {
	position: relative;
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	gap: 6px; text-align: center;
	min-height: 150px; padding: 20px 14px;
	border: 2px dashed var(--ds-line);
	border-radius: 12px;
	background: var(--ds-soft);
	color: var(--ds-muted);
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease;
}
.ds-drop:hover, .ds-drop.is-over, .ds-drop:focus-within {
	border-color: var(--ds-accent);
	background: color-mix(in srgb, var(--ds-accent) 6%, var(--ds-surface));
	color: var(--ds-ink);
}
.ds-drop:focus-within { outline: 2px solid var(--ds-accent); outline-offset: 2px; }
.ds-drop__icon { color: var(--ds-accent); }
.ds-drop__main { font-weight: 600; color: var(--ds-ink); }
.ds-drop__sub { font-size: 13px; }
.is-loading .ds-drop { opacity: .7; pointer-events: none; }

/* Input de archivo visualmente oculto pero accesible por teclado. */
.ds-input {
	position: absolute !important;
	width: 1px; height: 1px; margin: -1px; padding: 0;
	overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap;
}

.ds-chosen {
	display: flex; align-items: center; gap: 12px;
	min-height: 150px; padding: 16px;
	border-radius: 12px;
	background: color-mix(in srgb, var(--ds-accent) 7%, var(--ds-surface));
	color: var(--ds-accent);
}
.ds-chosen__info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ds-chosen__name { color: var(--ds-ink); overflow-wrap: anywhere; }
.ds-chosen__meta { font-size: 13px; color: var(--ds-muted); }

.ds-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.ds-cloud .ds-btn { flex: 1 1 130px; }

.ds-error {
	margin: 0; padding: 10px 12px;
	border-radius: 10px;
	background: var(--ds-del); color: var(--ds-del-ink);
	font-size: 14px;
}

.ds-swap {
	align-self: center;
	width: 42px; height: 42px; border-radius: 50%;
	display: grid; place-items: center;
	border: 1px solid var(--ds-line); background: var(--ds-surface); color: var(--ds-ink);
	cursor: pointer; padding: 0;
}
.ds-swap:hover { border-color: var(--ds-accent); color: var(--ds-accent); }

/* ---------- Botones ---------- */

.diffsheet .ds-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	padding: 10px 16px; min-height: 42px;
	border-radius: 10px; border: 1px solid transparent;
	font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2;
	text-decoration: none; cursor: pointer;
	transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.diffsheet .ds-btn--primary { background: var(--ds-accent); color: #fff; }
.diffsheet .ds-btn--primary:hover { background: color-mix(in srgb, var(--ds-accent) 86%, #000); color: #fff; }
.diffsheet .ds-btn--primary:disabled { background: #cbd5e1; color: #fff; cursor: not-allowed; }
.diffsheet .ds-btn--ghost { background: var(--ds-surface); color: var(--ds-ink); border-color: var(--ds-line); }
.diffsheet .ds-btn--ghost:hover { border-color: var(--ds-accent); color: var(--ds-accent); }
.diffsheet .ds-btn--lg { font-size: 17px; padding: 14px 28px; min-height: 52px; }
.diffsheet .ds-btn:focus-visible, .ds-swap:focus-visible, .ds-link:focus-visible, .ds-filter:focus-visible {
	outline: 2px solid var(--ds-accent); outline-offset: 2px;
}
.diffsheet .ds-link {
	background: none; border: 0; padding: 4px 6px; font: inherit; font-size: 14px; font-weight: 600;
	color: var(--ds-accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- Opciones y acciones ---------- */

.ds-options {
	margin-top: 14px;
	border: 1px solid var(--ds-line); border-radius: 12px;
	background: var(--ds-surface);
}
.ds-options summary { padding: 12px 16px; cursor: pointer; font-weight: 600; font-size: 15px; }
.ds-options__body {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 8px 18px; padding: 0 16px 14px; font-size: 15px;
}
.ds-options__body label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.ds-options__body input { accent-color: var(--ds-accent); width: 17px; height: 17px; margin: 0; }

.ds-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; text-align: center; }
.diffsheet .ds-privacy { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; font-size: 13px; color: var(--ds-muted); }
.diffsheet .ds-privacy a { color: inherit; text-decoration: underline; text-underline-offset: 2px; margin-left: 4px; }
.diffsheet .ds-privacy a:hover { color: var(--ds-accent); }

.ds-status {
	display: flex; align-items: center; justify-content: center; gap: 10px;
	margin-top: 14px; padding: 12px;
	border-radius: 10px; background: var(--ds-soft); font-size: 15px;
}
.ds-status.is-info .ds-spinner { display: none; }
.ds-spinner {
	width: 18px; height: 18px; border-radius: 50%;
	border: 2.5px solid var(--ds-line); border-top-color: var(--ds-accent);
}
@media (prefers-reduced-motion: no-preference) {
	.ds-spinner { animation: ds-spin .8s linear infinite; }
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ---------- Resultados ---------- */

.ds-results {
	margin-top: 22px; padding: 20px;
	border: 1px solid var(--ds-line); border-radius: var(--ds-radius);
	background: var(--ds-surface);
	scroll-margin-top: 80px;
}
.ds-results__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.ds-downloads { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.diffsheet .ds-downloads__label { font-size: 14px; font-weight: 600; color: var(--ds-muted); margin-right: 2px; }
.diffsheet .ds-dl { min-height: 38px; padding: 8px 14px; font-size: 14px; }
.diffsheet .ds-dl[aria-busy="true"] { cursor: progress; opacity: .75; }
.diffsheet .ds-dl[aria-busy="true"] svg { animation: none; }
@media (prefers-reduced-motion: no-preference) {
	.diffsheet .ds-dl[aria-busy="true"] svg { animation: ds-bob .9s ease-in-out infinite; }
}
@keyframes ds-bob { 50% { transform: translateY(3px); } }
@media (max-width: 560px) { .ds-downloads { width: 100%; } .diffsheet .ds-dl { flex: 1 1 auto; } .ds-downloads__label { width: 100%; } }
.diffsheet .ds-results__title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; color: var(--ds-ink); }
.ds-results.is-identical .ds-results__title { color: var(--ds-add-ink); }

.ds-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
@media (max-width: 480px) { .ds-tiles { grid-template-columns: 1fr 1fr; } .ds-tile__value { font-size: 20px; } }
.ds-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--ds-soft); }
.ds-tile__value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ds-tile__label { font-size: 13px; color: var(--ds-muted); }
.ds-tile--mod { background: var(--ds-mod); } .ds-tile--mod .ds-tile__value { color: var(--ds-mod-ink); }
.ds-tile--add { background: var(--ds-add); } .ds-tile--add .ds-tile__value { color: var(--ds-add-ink); }
.ds-tile--del { background: var(--ds-del); } .ds-tile--del .ds-tile__value { color: var(--ds-del-ink); }

.ds-sheets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ds-sheet {
	display: inline-flex; gap: 6px; align-items: baseline;
	padding: 5px 10px; border-radius: 999px; font-size: 13px;
	border: 1px solid var(--ds-line); background: var(--ds-soft);
}
.ds-sheet span { color: var(--ds-muted); }
.ds-sheet--modified { background: var(--ds-mod); border-color: transparent; }
.ds-sheet--added { background: var(--ds-add); border-color: transparent; }
.ds-sheet--deleted { background: var(--ds-del); border-color: transparent; }

.ds-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.diffsheet .ds-filter {
	padding: 6px 12px; border-radius: 999px;
	border: 1px solid var(--ds-line); background: var(--ds-surface); color: var(--ds-ink);
	font: inherit; font-size: 13px; cursor: pointer;
}
.diffsheet .ds-filter[aria-pressed="true"] { background: var(--ds-ink); border-color: var(--ds-ink); color: #fff; }

.ds-table-wrap {
	margin-top: 12px; max-height: 480px; overflow: auto;
	border: 1px solid var(--ds-line); border-radius: 10px;
}
.diffsheet .ds-table { width: 100%; min-width: 680px; margin: 0; border-collapse: collapse; font-size: 14px; background: var(--ds-surface); }
.diffsheet .ds-table th {
	position: sticky; top: 0; z-index: 1;
	background: var(--ds-soft); text-align: left; font-weight: 600;
	padding: 9px 12px; border: 0; border-bottom: 1px solid var(--ds-line); white-space: nowrap;
}
.diffsheet .ds-table td { padding: 8px 12px; border: 0; border-bottom: 1px solid var(--ds-line); vertical-align: top; overflow-wrap: break-word; }
.diffsheet .ds-table td:first-child { white-space: nowrap; }
.diffsheet .ds-table tr:last-child td { border-bottom: 0; }
.ds-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; white-space: nowrap; }
.ds-before { color: var(--ds-del-ink); }
.ds-after { color: var(--ds-add-ink); }
.ds-row--mod .ds-before { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ds-del-ink) 50%, transparent); }

.ds-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.ds-tag--mod { background: var(--ds-mod); color: var(--ds-mod-ink); }
.ds-tag--add { background: var(--ds-add); color: var(--ds-add-ink); }
.ds-tag--del { background: var(--ds-del); color: var(--ds-del-ink); }
.ds-tag--neutral { background: var(--ds-soft); color: var(--ds-ink); }

.diffsheet .ds-note { margin: 10px 0 0; font-size: 13px; color: var(--ds-muted); }

.diffsheet--locked { padding: 24px; text-align: center; border: 1px solid var(--ds-line); border-radius: var(--ds-radius); }

/* ---------- Documento combinado (vista tipo hoja de cálculo) ---------- */

.ds-merge { margin-top: 22px; border: 1px solid var(--ds-line); border-radius: 12px; overflow: hidden; background: var(--ds-surface); }
.ds-merge[hidden] { display: none !important; }
.ds-merge__bar {
	display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
	padding: 12px 14px; border-bottom: 1px solid var(--ds-line); background: var(--ds-soft);
}
.diffsheet .ds-merge__title { margin: 0; font-size: 16px; font-weight: 700; color: var(--ds-ink); margin-right: auto; }
.ds-legend { display: flex; flex-wrap: wrap; gap: 8px; }
.ds-legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ds-ink); }
.ds-legend__item::before { content: ""; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.12); }
.ds-legend__item--mod::before { background: var(--ds-mod); }
.ds-legend__item--add::before { background: var(--ds-add); }
.ds-legend__item--del::before { background: var(--ds-del); }
.ds-merge__only { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.ds-merge__only input { accent-color: var(--ds-accent); margin: 0; }

.ds-merge__grid { max-height: 520px; overflow: auto; background: #fff; }
.diffsheet .ds-grid {
	border-collapse: separate; border-spacing: 0; margin: 0; width: max-content; min-width: 100%;
	font: 13px/1.35 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Calibri, Arial, sans-serif;
	color: #111827; background: #fff; table-layout: auto;
}
.diffsheet .ds-grid th, .diffsheet .ds-grid td {
	border: 0; border-right: 1px solid #e2e5ea; border-bottom: 1px solid #e2e5ea;
	padding: 4px 8px; height: 24px; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.diffsheet .ds-grid thead th {
	position: sticky; top: 0; z-index: 2; background: #f3f4f6; color: #4b5563;
	font-weight: 500; text-align: center; min-width: 64px;
}
.diffsheet .ds-grid tbody th {
	position: sticky; left: 0; z-index: 1; background: #f3f4f6; color: #6b7280;
	font-weight: 400; text-align: right; min-width: 44px; cursor: default;
}
.diffsheet .ds-grid .ds-grid__corner { left: 0; z-index: 3; min-width: 44px; }
.diffsheet .ds-grid thead th.is-a { background: #b7dfa3; color: #1f4d10; }
.diffsheet .ds-grid thead th.is-d { background: #f3b4b4; color: #7a0000; }
.diffsheet .ds-grid tbody tr.is-a th { background: #b7dfa3; color: #1f4d10; font-weight: 600; }
.diffsheet .ds-grid tbody tr.is-d th { background: #f3b4b4; color: #7a0000; font-weight: 600; }
.diffsheet .ds-grid tbody tr.is-m th { background: #ffe599; color: #6b4e00; font-weight: 600; }
.diffsheet .ds-grid td.is-m { background: var(--ds-mod); }
.diffsheet .ds-grid td.is-a { background: var(--ds-add); }
.diffsheet .ds-grid td.is-d { background: var(--ds-del); color: var(--ds-del-ink); text-decoration: line-through; }
.diffsheet .ds-grid td.has-old { cursor: help; box-shadow: inset 0 0 0 1px #e0b400; }
.diffsheet .ds-grid td.has-old::after { content: ""; float: right; width: 0; height: 0; margin: -4px -8px 0 6px; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent #d97706 transparent transparent; }
.diffsheet .ds-grid .ds-grid__empty { text-align: center; color: var(--ds-muted); padding: 24px; max-width: none; }

.ds-merge__tabs {
	display: flex; gap: 2px; overflow-x: auto; padding: 0 8px; border-top: 1px solid var(--ds-line); background: #eef0f3;
	scrollbar-width: thin;
}
.diffsheet .ds-tab {
	position: relative; flex: none; margin: 0 0 4px; padding: 7px 14px 6px; border: 0; border-radius: 0 0 8px 8px;
	background: transparent; color: #374151; font: inherit; font-size: 13px; cursor: pointer; max-width: 200px;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: inset 0 3px 0 transparent;
}
.diffsheet .ds-tab:hover { background: #e2e5ea; }
.diffsheet .ds-tab[aria-selected="true"] { background: #fff; color: var(--ds-ink); font-weight: 600; }
.diffsheet .ds-tab--modified { box-shadow: inset 0 3px 0 #ffc000; }
.diffsheet .ds-tab--added { box-shadow: inset 0 3px 0 #70ad47; }
.diffsheet .ds-tab--deleted { box-shadow: inset 0 3px 0 #e06666; }
.diffsheet .ds-tab--deleted .ds-tab__name { text-decoration: line-through; }
.diffsheet .ds-tab--renamed { box-shadow: inset 0 3px 0 #5b9bd5; }
.diffsheet .ds-tab:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: -2px; }

.ds-merge__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; }
.ds-merge__foot:has(.ds-merge__note:empty):has([data-action="more-rows"][hidden]) { display: none; }
.diffsheet .ds-merge__note { margin: 0; font-size: 13px; color: var(--ds-muted); }
.diffsheet .ds-list-title { margin: 26px 0 0; font-size: 16px; font-weight: 700; color: var(--ds-ink); }
.diffsheet .ds-grid td.is-merged { max-width: none; }
.diffsheet .ds-grid tr.ds-grid__gap th, .diffsheet .ds-grid tr.ds-grid__gap td { height: 14px; padding: 0 8px; background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e9ebef 6px, #e9ebef 12px); color: #9ca3af; font-size: 11px; line-height: 14px; }
