:root {
  --fondo-1: #0f172a;
  --fondo-2: #1e1b4b;
  --tarjeta: #ffffff;
  --texto: #0f172a;
  --muted: #64748b;
  --borde: #e2e8f0;
  --primario: #6366f1;
  --primario-2: #ec4899;
  --ok: #10b981;
  --aviso: #f59e0b;
  --peligro: #ef4444;
  --radio: 18px;
  --sombra: 0 20px 50px -20px rgba(15, 23, 42, .55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--texto);
  background:
    radial-gradient(1100px 600px at 5% -10%, rgba(99, 102, 241, .55) 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(236, 72, 153, .45) 0%, transparent 55%),
    linear-gradient(160deg, var(--fondo-1), var(--fondo-2));
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primario); }

/* ---------- Cabecera ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  color: #fff;
}
.marca {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .2px;
}
.logo {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primario), var(--primario-2));
  box-shadow: 0 8px 20px -6px rgba(99, 102, 241, .8);
}
.nav { display: flex; align-items: center; gap: 14px; }
.nav a { color: rgba(255,255,255,.85); text-decoration: none; font-weight: 500; }
.nav a:hover { color: #fff; }
.inline { display: inline; }
.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: rgba(255,255,255,.75); font: inherit; font-weight: 500;
}
.link:hover { color: #fff; text-decoration: underline; }

/* ---------- Contenido ---------- */
.contenido {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px clamp(16px, 4vw, 40px) 48px;
}
.pie {
  text-align: center;
  padding: 20px;
  color: rgba(255,255,255,.55);
  font-size: .85rem;
}

.hero { text-align: center; color: #fff; padding: 28px 0 24px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 10px; letter-spacing: -.5px; }
.hero p { margin: 0 auto; max-width: 560px; color: rgba(255,255,255,.8); font-size: 1.05rem; }
.hero .btn { margin-top: 20px; }

.cabecera-seccion {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  color: #fff; padding: 20px 0 22px;
}
.cabecera-seccion h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.4px; }
.cabecera-seccion .muted { color: rgba(255,255,255,.75); margin: 0; }
.cabecera-seccion .badge { vertical-align: middle; }
.titulo-fichero { word-break: break-word; }
.volver { color: rgba(255,255,255,.75); text-decoration: none; font-size: .9rem; }
.volver:hover { color: #fff; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--tarjeta);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: clamp(20px, 3vw, 32px);
}
.card h2 { margin: 0 0 18px; font-size: 1.15rem; }
.card h3 { margin: 26px 0 10px; font-size: 1rem; }
.card-estrecha { max-width: 480px; margin: 0 auto; }
.card-media { max-width: 680px; margin: 0 auto; }
.columnas { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 860px) { .columnas { grid-template-columns: 1fr; } }

.vacio { text-align: center; padding: 48px 24px; }
.vacio h2 { margin-bottom: 8px; }
.vacio .btn { margin-top: 18px; }

/* ---------- Formularios ---------- */
.formulario { display: flex; flex-direction: column; gap: 18px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > span { font-weight: 600; font-size: .92rem; }
.campo small { color: var(--muted); font-size: .8rem; }
.fila { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 560px) { .fila { grid-template-columns: 1fr; } }

input[type=text], input[type=email], input[type=password], input[type=number], textarea {
  width: 100%;
  font: inherit;
  padding: 13px 14px;
  border: 1.5px solid var(--borde);
  border-radius: 12px;
  background: #f8fafc;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primario);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .18);
}
textarea { resize: vertical; }
.token {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: .25em;
  font-size: 1.15rem;
  text-align: center;
}
.token-grande { font-size: 1.5rem; font-weight: 700; color: var(--primario); }
.mensaje { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.5; }

.copiar { display: flex; gap: 8px; }
.copiar input { flex: 1; min-width: 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 22px;
  border: 0; border-radius: 14px;
  font: inherit; font-weight: 700; font-size: .98rem;
  color: #fff; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: linear-gradient(135deg, var(--primario), var(--primario-2));
  box-shadow: 0 10px 24px -10px rgba(99, 102, 241, .9);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(236, 72, 153, .8); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }
.btn-grande { padding: 16px 28px; font-size: 1.08rem; border-radius: 16px; }
.btn-sm { padding: 8px 14px; font-size: .85rem; border-radius: 10px; }
.btn-bloque { width: 100%; }
.btn-secundario { background: #eef2ff; color: var(--primario); box-shadow: none; }
.btn-secundario:hover { box-shadow: none; background: #e0e7ff; }
.btn-ok { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 10px 24px -10px rgba(16, 185, 129, .9); }
.btn-aviso { background: linear-gradient(135deg, #f59e0b, #ea580c); box-shadow: 0 10px 24px -10px rgba(245, 158, 11, .9); }
.btn-peligro { background: linear-gradient(135deg, #ef4444, #be123c); box-shadow: 0 10px 24px -10px rgba(239, 68, 68, .9); }
.btn.copiado { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.acciones-col { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Avisos ---------- */
.alerta { padding: 12px 16px; border-radius: 12px; font-weight: 500; }
.alerta-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alerta-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; margin-top: 8px; }
.oculto { display: none !important; }
.muted { color: var(--muted); }
.pequeno { font-size: .82rem; }
.centrado { text-align: center; }
.nota { background: #f8fafc; border-left: 4px solid var(--primario); padding: 12px 14px; border-radius: 8px; margin: 16px 0; white-space: pre-wrap; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-activa { background: #d1fae5; color: #065f46; }
.badge-caducada { background: #fef3c7; color: #92400e; }
.badge-agotada { background: #e0e7ff; color: #3730a3; }
.badge-revocada { background: #fee2e2; color: #991b1b; }

.codigo { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .08em; }

/* ---------- Estadísticas ---------- */
.estadisticas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 560px) { .estadisticas { grid-template-columns: 1fr; } }
.stat {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  color: #fff; border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px;
  backdrop-filter: blur(6px);
}
.stat-valor { font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; }
.stat-etiqueta { color: rgba(255,255,255,.7); font-size: .85rem; }

/* ---------- Tabla ---------- */
.tabla-wrap { padding: 8px; overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tabla th, .tabla td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--borde); }
.tabla th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: #f8fafc; }
.num { text-align: right !important; }
.acciones { white-space: nowrap; text-align: right !important; }
.acciones .btn { margin-left: 6px; }
.enlace-fuerte { font-weight: 600; color: var(--texto); text-decoration: none; word-break: break-word; }
.enlace-fuerte:hover { color: var(--primario); }

/* ---------- Detalles ---------- */
.detalles { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 20px; font-size: .95rem; }
.detalles dt { color: var(--muted); font-weight: 500; }
.detalles dd { margin: 0; }
.historial { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.historial li { padding: 6px 0; border-bottom: 1px dashed var(--borde); }
.historial li:last-child { border-bottom: 0; }

/* ---------- Fichero listo ---------- */
.icono-ok {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 16px 36px -12px rgba(16, 185, 129, .9);
}
.fichero { display: flex; align-items: center; gap: 16px; padding: 16px; background: #f8fafc; border-radius: 14px; margin-bottom: 18px; }
.fichero-icono { color: var(--primario); flex-shrink: 0; }
.fichero-datos { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fichero-nombre { word-break: break-word; }
.codigo-error { font-size: 5rem; font-weight: 900; opacity: .25; line-height: 1; margin-bottom: 8px; }

/* ---------- Dropzone y progreso ---------- */
.dropzone {
  position: relative;
  border: 2px dashed #c7d2fe;
  border-radius: 16px;
  padding: 36px 20px;
  text-align: center;
  background: #f5f3ff;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-within, .dropzone.activo { border-color: var(--primario); background: #ede9fe; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone-vacio, .dropzone-lleno { display: flex; flex-direction: column; gap: 6px; align-items: center; color: var(--primario); pointer-events: none; }
.dropzone-vacio strong { color: var(--texto); font-size: 1.05rem; }
.dropzone-lleno strong { color: var(--texto); font-size: 1.05rem; word-break: break-all; }

.progreso { display: flex; flex-direction: column; gap: 6px; }
.progreso-barra { height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progreso-relleno { height: 100%; width: 0; background: linear-gradient(90deg, var(--primario), var(--primario-2)); transition: width .2s; }
