:root {
  --ink: #0b1220;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f9ff;
  --card: #ffffff;

  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06);
  --shadow-md: 0 10px 30px -12px rgba(37,99,235,.28), 0 4px 10px -6px rgba(15,23,42,.12);
  --shadow-lg: 0 30px 60px -20px rgba(37,99,235,.35);

  /* Colores por categoría de entidad */
  --c-persona: #2563eb;   --c-persona-bg: #e8f0ff;
  --c-id: #7c3aed;        --c-id-bg: #f1ebfe;
  --c-email: #0e9488;     --c-email-bg: #e1f5f2;
  --c-telefono: #0f9d58;  --c-telefono-bg: #e3f5ea;
  --c-ubicacion: #d97706; --c-ubicacion-bg: #fdf0db;
  --c-iban: #e11d62;      --c-iban-bg: #fde8ef;
  --c-fecha: #475569;     --c-fecha-bg: #eef1f6;
  --c-otros: #0891b2;     --c-otros-bg: #e0f4fa;

  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: min(1280px, 94vw); margin-inline: auto; }

/* Fondo ambiental azul */
.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(60% 50% at 80% -5%, #dbeafe 0%, transparent 60%),
    radial-gradient(45% 40% at 5% 5%, #e8efff 0%, transparent 55%),
    var(--bg);
}

/* Header */
.site-header { padding: 16px 0; }
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(145deg, var(--blue-600), var(--blue-700));
  color: #fff; box-shadow: var(--shadow-md);
}
.brand-accent { color: var(--blue-600); }
.pill {
  font-size: .78rem; font-weight: 600; color: var(--blue-700);
  background: var(--blue-50); border: 1px solid var(--blue-100);
  padding: 6px 12px; border-radius: 999px;
}

/* Landing: dos columnas en escritorio (explicación | formulario) */
.landing {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 52px;
  align-items: center; padding: 40px 0 56px;
}
.intro { max-width: 560px; }
.eyebrow {
  font-size: .76rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--blue-600); margin: 0 0 12px;
}
.intro h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.9rem); line-height: 1.08; letter-spacing: -.03em;
  font-weight: 800; margin: 0 0 16px;
}
.grad {
  background: linear-gradient(100deg, var(--blue-600), #60a5fa);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { font-size: 1.05rem; color: var(--ink-soft); margin: 0 0 26px; max-width: 52ch; }

.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.features li { display: flex; align-items: flex-start; gap: 13px; }
.features li strong { display: block; font-size: .95rem; font-weight: 700; color: var(--ink); }
.features li div span { display: block; font-size: .85rem; color: var(--muted); margin-top: 1px; }
.feat-ico {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  background: var(--blue-50); border: 1px solid var(--blue-100);
  display: grid; place-items: center;
}
.feat-ico::before {
  content: ""; width: 19px; height: 19px;
  background: var(--blue-600); -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.feat-ico[data-c="id"]::before   { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='12' r='2.5'/%3E%3Cpath d='M14 10h4M14 14h4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='12' r='2.5'/%3E%3Cpath d='M14 10h4M14 14h4'/%3E%3C/svg%3E"); }
.feat-ico[data-c="map"]::before  { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h7M4 12h5M4 17h8'/%3E%3Cpath d='M15 8l5 4-5 4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h7M4 12h5M4 17h8'/%3E%3Cpath d='M15 8l5 4-5 4'/%3E%3C/svg%3E"); }
.feat-ico[data-c="lock"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='10' width='16' height='10' rx='2'/%3E%3Cpath d='M8 10V7a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='10' width='16' height='10' rx='2'/%3E%3Cpath d='M8 10V7a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E"); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 28px;
}
.upload-card { margin: 0; box-shadow: var(--shadow-md); }
.card-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.card-sub { color: var(--muted); margin: 0 0 22px; font-size: .92rem; }

.ref-field { display: block; margin-bottom: 16px; }
.ref-field span { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 7px; }
.ref-field input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: .95rem; background: #fbfdff; transition: border-color .15s, box-shadow .15s;
}
.ref-field input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 4px var(--blue-100); }

/* Selector de nivel de análisis */
.field-label { font-size: .82rem; font-weight: 700; color: var(--ink-soft); margin: 0 0 8px; }
.level-select { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.level-btn {
  position: relative; text-align: left; background: #fbfdff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 15px; cursor: pointer; font: inherit; transition: border-color .15s, background .15s, box-shadow .15s;
}
.level-btn strong { display: block; font-size: .98rem; font-weight: 700; color: var(--ink); }
.level-btn span:not(.level-tag) { display: block; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.level-btn:hover { border-color: #93c5fd; }
.level-btn.active { border-color: var(--blue-600); background: var(--blue-50); box-shadow: 0 0 0 3px var(--blue-100); }
.level-btn.active strong { color: var(--blue-700); }
.level-tag {
  position: absolute; top: -9px; right: 12px; font-size: .66rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: #fff; background: var(--blue-600); padding: 3px 9px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

/* Dropzone */
.dropzone {
  position: relative; border: 2px dashed #c7d7f5; border-radius: var(--radius);
  background: linear-gradient(180deg, #fbfdff, #f3f8ff);
  padding: 40px 24px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--blue-500); background: var(--blue-50); outline: none; }
.dropzone.dragover { border-color: var(--blue-600); background: var(--blue-100); transform: scale(1.01); }
.dz-ico { color: var(--blue-600); margin-bottom: 6px; }
.dz-title { font-weight: 700; margin: 4px 0 2px; }
.dz-or { color: var(--muted); font-size: .9rem; margin: 0 0 16px; }
.linklike { background: none; border: none; color: var(--blue-600); font: inherit; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.dz-types { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dz-types span {
  font-family: var(--font-mono); font-size: .72rem; font-weight: 500; color: var(--blue-700);
  background: #fff; border: 1px solid var(--blue-100); padding: 4px 9px; border-radius: 7px;
}

.file-chosen {
  display: flex; align-items: center; gap: 10px; margin-top: 16px;
  background: var(--blue-50); border: 1px solid var(--blue-100); border-radius: var(--radius-sm); padding: 12px 14px;
}
.file-chosen[hidden] { display: none; }
.fc-ico { flex: none; width: 20px; height: 20px; border-radius: 5px; background: var(--blue-600); }
.fc-name { flex: 1; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-clear { border: none; background: #fff; color: var(--muted); width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.fc-clear:hover { color: var(--c-iban); }

/* Buttons */
.btn-primary {
  margin-top: 22px; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700)); color: #fff;
  border: none; border-radius: var(--radius-sm); padding: 15px 20px; font: inherit; font-weight: 700; font-size: 1rem;
  cursor: pointer; box-shadow: var(--shadow-md); transition: transform .15s, box-shadow .15s, opacity .2s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: #fff; color: var(--blue-700); border: 1px solid var(--blue-100); border-radius: var(--radius-sm);
  padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--blue-50); border-color: var(--blue-500); }
.btn-ghost.sm { padding: 9px 14px; font-size: .88rem; }

/* Botón de descarga destacado (grande y accesible) */
.btn-download {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  margin: 0 0 22px; padding: 18px 24px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700)); color: #fff;
  border: none; border-radius: var(--radius); font: inherit; font-weight: 800; font-size: 1.08rem;
  letter-spacing: -.01em; cursor: pointer; box-shadow: var(--shadow-md);
  transition: transform .15s, box-shadow .15s;
}
.btn-download svg { flex: none; }
.btn-download:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-download:active { transform: translateY(0); }
.btn-download:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--blue-100), var(--shadow-md); }

/* State cards */
.state-card { max-width: 640px; margin: 0 0 64px; text-align: center; }
.state-card.error { border-color: #fbcfe0; background: #fff7fa; }
.state-title { font-weight: 700; font-size: 1.1rem; margin: 16px 0 4px; }
.state-sub { color: var(--muted); margin: 0 0 18px; font-size: .92rem; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--blue-100); border-top-color: var(--blue-600); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.results { margin-bottom: 80px; animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.results-head h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.results-file { color: var(--muted); font-size: .9rem; margin: 2px 0 0; font-family: var(--font-mono); }
.results-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--ink-soft); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s; flex: none; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--blue-600); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px var(--blue-100); }

/* Stats */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.stat {
  display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px 8px 10px; font-size: .85rem; font-weight: 600; box-shadow: var(--shadow-sm);
}
.stat .dot { width: 9px; height: 9px; border-radius: 50%; }
.stat .n { font-family: var(--font-mono); color: var(--muted); font-weight: 600; }

/* Panels */
.panels { display: grid; grid-template-columns: 1.05fr .95fr; gap: 20px; }
.panel { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; }
.panel-head h3 { font-size: 1.05rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 9px; }
.count-badge { font-family: var(--font-mono); font-size: .78rem; background: var(--blue-600); color: #fff; padding: 2px 9px; border-radius: 999px; }
.panel-hint { color: var(--muted); font-size: .82rem; padding: 4px 22px 14px; margin: 0; border-bottom: 1px solid var(--line); }
.copy-btn { background: var(--blue-50); border: 1px solid var(--blue-100); color: var(--blue-700); border-radius: 8px; padding: 6px 12px; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.copy-btn:hover { background: var(--blue-100); }

.anon-text {
  font-family: var(--font-mono); font-size: .86rem; line-height: 1.85; color: var(--ink-soft);
  white-space: pre-wrap; word-break: break-word; padding: 20px 22px; max-height: 540px; overflow-y: auto;
}

/* Token chips dentro del texto */
.tok {
  font-weight: 600; padding: 1px 7px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; transition: box-shadow .15s, transform .1s; white-space: nowrap;
}
.tok.flash { animation: flash 1.1s ease; }
@keyframes flash { 0%,100% { box-shadow: 0 0 0 0 transparent; } 25% { box-shadow: 0 0 0 4px rgba(37,99,235,.35); transform: scale(1.04); } }

/* Fields list */
.fields { padding: 10px; max-height: 540px; overflow-y: auto; display: grid; gap: 7px; }
.field {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  cursor: default; transition: border-color .15s, background .15s, box-shadow .15s;
}
.field:hover, .field.active { border-color: var(--blue-500); background: var(--blue-50); box-shadow: var(--shadow-sm); }
.field .f-token { font-family: var(--font-mono); font-size: .8rem; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.field .f-body { min-width: 0; }
.field .f-type { font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.field .f-value { font-family: var(--font-mono); font-size: .85rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field .f-value.hidden-val { color: var(--muted); letter-spacing: .12em; }
.field .f-score { font-family: var(--font-mono); font-size: .74rem; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 30px 16px; font-size: .9rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0; background: #fff; }
.site-footer p { color: var(--muted); font-size: .85rem; margin: 0; text-align: center; }

/* Responsive */
@media (max-width: 980px) {
  /* En móvil/tablet: una sola columna, primero el formulario */
  .landing { grid-template-columns: 1fr; gap: 28px; padding: 22px 0 36px; }
  .intro { max-width: none; order: 2; }
  .upload-card { order: 1; }
  .panels { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
